diff --git a/sdk/authorization/azure-mgmt-authorization/README.md b/sdk/authorization/azure-mgmt-authorization/README.md index ee0db8650f6a..a4dc9ba62af9 100644 --- a/sdk/authorization/azure-mgmt-authorization/README.md +++ b/sdk/authorization/azure-mgmt-authorization/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Authorization Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-authorization%2FREADME.png) diff --git a/sdk/authorization/azure-mgmt-authorization/_meta.json b/sdk/authorization/azure-mgmt-authorization/_meta.json index ca36520af982..20ba6953d4ba 100644 --- a/sdk/authorization/azure-mgmt-authorization/_meta.json +++ b/sdk/authorization/azure-mgmt-authorization/_meta.json @@ -1,11 +1,29 @@ { - "commit": "1af2861030243b06ee35172c95899f4809eedfc7", + "commit": "d35ccd6e129d8b4ec9d802f149c45f5907c6ad18", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.6.0", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/authorization/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/authorization/resource-manager/readme.md" + "autorest_command": "autorest specification/authorization/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/authorization/resource-manager/readme.md", + "package-2022-08-01-preview-only": "2023-02-17 06:42:30 -0800 66e7f9b04a2325fe00afd04d8abdab6ed78b7c4a Microsoft.Authorization/preview/2022-08-01-preview/RoleManagementAlerts.json", + "package-2022-05-01-preview-only": "2023-06-20 23:40:41 -0700 526e6049f46d58a5077850731dce19ab9767988f Microsoft.Authorization/preview/2022-05-01-preview/common-types.json", + "package-2022-04-01-only": "2024-10-31 13:20:17 -0700 531d4298f9e88c226c55a6cd51af8d7f5d73d503 Microsoft.Authorization/stable/2022-04-01/authorization-DenyAssignmentCalls.json", + "package-2022-04-01-preview-only": "2022-02-28 18:24:29 -0800 e785020b4fcd3b1e5d7943d9a0d59ad36ef4d7f8 Microsoft.Authorization/preview/2022-04-01-preview/RoleEligibilityScheduleRequest.json", + "package-2021-12-01-preview-python-only": "2022-06-29 21:34:39 -0700 a4d7a85899e7b980990870106224524ec6438c8a Microsoft.Authorization/preview/2021-12-01-preview/authorization-AccessReviewCalls.json", + "package-2021-07-01-preview-only": "2021-07-29 01:50:48 -0700 74dbcfee45a6634d0043e478aba324796d98940c Microsoft.Authorization/preview/2021-07-01-preview/authorization-AccessReviewCalls.json", + "package-2021-03-01-preview-only": "2021-04-21 00:47:59 -0700 890f0755f2a973edadc31c78d7a74f5e283f6c3d Microsoft.Authorization/preview/2021-03-01-preview/authorization-AccessReviewCalls.json", + "package-2021-01-01-preview-only": "2021-02-18 00:34:14 -0800 c740df72bd77fd8c6a822bbd1ad8d366a31dc2b3 Microsoft.Authorization/preview/2021-01-01-preview/authorization-RoleAssignmentApprovalCalls.json", + "package-2020-10-01-only": "2022-03-31 17:46:02 -0700 95a128e006b4478203e188c9bf8896ffe9900998 Microsoft.Authorization/stable/2020-10-01/common-types.json", + "package-2020-10-01-preview-only": "2023-06-20 23:40:41 -0700 526e6049f46d58a5077850731dce19ab9767988f Microsoft.Authorization/preview/2020-10-01-preview/RoleManagementPolicy.json", + "package-2020-04-01-preview-only": "2021-11-03 18:26:47 -0700 42c2ad511bc23ece4f224a67eb35c598280c6dcf Microsoft.Authorization/preview/2020-04-01-preview/authorization-RoleAssignmentsCalls.json", + "package-2019-08-01-preview-only": "2021-08-31 20:25:39 -0700 4dc391780cb36a5c8c5632f5baec0cb8f255fa71 Microsoft.Authorization/preview/2019-08-01-preview/authorization-UsageMetricsCalls.json", + "package-2018-09-01-preview-only": "2021-11-03 18:26:47 -0700 42c2ad511bc23ece4f224a67eb35c598280c6dcf Microsoft.Authorization/preview/2018-09-01-preview/authorization-RoleAssignmentsCalls.json", + "package-2018-07-01-preview-only": "2022-02-10 03:42:48 +0100 47c12e21d06ca29be0579880585fc883bd6e6055 Microsoft.Authorization/preview/2018-07-01-preview/authorization-DenyAssignmentGetCalls.json", + "package-2018-05-01-preview": "2022-02-10 03:42:48 +0100 47c12e21d06ca29be0579880585fc883bd6e6055 Microsoft.Authorization/preview/2018-05-01-preview/authorization-AccessReviewCalls.json", + "package-2018-01-01-preview-only": "2022-02-10 03:42:48 +0100 47c12e21d06ca29be0579880585fc883bd6e6055 Microsoft.Authorization/preview/2018-01-01-preview/authorization-RoleDefinitionsCalls.json", + "package-2015-07-01": "2022-06-01 00:48:33 -0700 688cfd36391115f70ea9276a8e526caea6a5c8ad Microsoft.Authorization/stable/2015-07-01/authorization-ElevateAccessCalls.json", + "package-2015-06-01-preview": "2021-08-31 20:25:39 -0700 4dc391780cb36a5c8c5632f5baec0cb8f255fa71 Microsoft.Authorization/preview/2015-06-01/authorization-ClassicAdminCalls.json" } \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py index 381d561b2425..928fd9cef53e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -117,7 +120,25 @@ def __init__( if api_version: kwargs.setdefault('api_version', api_version) self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, profile=profile diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py index f52b9ee54234..da56a57b0cd1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- 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 @@ -20,7 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration: """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_serialization.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_serialization.py index e3cc6ce6ed6f..59f1fcf71bc9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_serialization.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # 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 @@ -143,7 +143,9 @@ def _json_attemp(data): # 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("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -392,7 +387,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -417,7 +412,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -447,7 +442,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -547,7 +542,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]]=None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -563,7 +558,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -651,7 +646,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): 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) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -664,12 +659,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -711,7 +707,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -731,6 +727,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -743,7 +740,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -751,10 +750,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get('skip_quote', False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -805,7 +802,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -825,7 +822,7 @@ def serialize_data(self, data, data_type, **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) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -893,6 +890,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -905,9 +904,18 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get('do_quote', False): + serialized = [ + '' if s is None else quote(str(s), safe='') + for s + in serialized + ] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -952,7 +960,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -985,7 +995,7 @@ def serialize_object(self, attr, **kwargs): 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: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1162,10 +1172,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1201,7 +1211,6 @@ def rest_key_extractor(attr, attr_desc, 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:]) @@ -1222,7 +1231,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, 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:]) @@ -1363,7 +1371,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]]=None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1383,7 +1391,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = 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 @@ -1436,12 +1444,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1473,7 +1481,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1507,14 +1515,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1570,7 +1578,7 @@ def _unpack_content(raw_data, content_type=None): 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"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1644,7 +1652,7 @@ def deserialize_data(self, data, data_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) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1692,7 +1700,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1749,7 +1757,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1800,7 +1808,6 @@ def deserialize_enum(data, enum_obj): 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: @@ -1854,10 +1861,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1885,7 +1892,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1902,7 +1909,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1937,7 +1944,7 @@ def deserialize_rfc(attr): 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) + raise DeserializationError(msg) from err else: return date_obj @@ -1974,7 +1981,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1990,9 +1997,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) 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) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py index 030b0658dbf1..e59b2fb6a7d0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -117,7 +120,25 @@ def __init__( if api_version: kwargs.setdefault('api_version', api_version) self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, profile=profile diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py index a9ce559ac2cf..53b71e9a9f2b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- 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 @@ -20,7 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration: """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py index f12a37a96c66..d858912e27c4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -62,7 +83,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2015-06-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -82,12 +103,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py index c8842b7e5fa2..da211f13a52f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json index aa6ebd5cdd75..161138ba5392 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "classic_administrators": "ClassicAdministratorsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py index 79efd40a81ac..dbd88f3c619e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -62,7 +83,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2015-06-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -82,12 +105,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py index b6f433c3f247..6f9b80047fa4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py index 8fc7122b7b46..1309ffe18188 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._classic_administrators_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators 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 ClassicAdministrator or the result of cls(response) :rtype: @@ -70,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +83,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +100,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py index 477ad39de894..178613f5fe2b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators 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 ClassicAdministrator or the result of cls(response) :rtype: @@ -99,7 +101,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,15 +112,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -129,14 +129,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) @@ -146,11 +145,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,5 +161,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py index aaccd7c597f8..e98537a343f6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -73,7 +76,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -98,7 +119,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2015-07-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -118,12 +139,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py index 9754fc6dc41c..dc6457dd497f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-07-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json index a3fd15ea9150..3a65e7bbd6b1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "permissions": "PermissionsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py index 0462fd81915f..0e55760cd17a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -73,7 +76,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -98,7 +119,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2015-07-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -118,12 +141,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py index 05ba4ebb00d5..588b103907a9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-07-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py index 2ff0577ad8a4..ca530d99a352 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._classic_administrators_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators 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 ClassicAdministrator or the result of cls(response) :rtype: @@ -70,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +83,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +100,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py index 0c066f8be930..46a317b23a7a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._global_administrator_operations import build_elevate_access_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,12 +58,11 @@ def __init__(self, *args, **kwargs) -> None: async def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Elevates access for a Global Administrator. - :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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -74,18 +76,16 @@ async def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=incons api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_elevate_access_request( + _request = build_elevate_access_request( api_version=api_version, - template_url=self.elevate_access.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -96,6 +96,4 @@ async def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=incons raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - elevate_access.metadata = {"url": "/providers/Microsoft.Authorization/elevateAccess"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py index f7dc7c98768f..657e19aa2104 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +63,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As :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 Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] @@ -72,7 +74,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,16 +85,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -103,14 +103,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -120,11 +119,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,10 +136,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -164,7 +159,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] @@ -176,7 +170,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +181,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -195,12 +189,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -211,14 +203,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -228,11 +219,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,7 +235,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py index 364a0a8c192c..21523338eec4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._provider_operations_metadata_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,12 +67,11 @@ async def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,20 +85,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,14 +106,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_models.ProviderOperationsMetadata"]: @@ -121,7 +119,6 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :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 ProviderOperationsMetadata or the result of cls(response) :rtype: @@ -134,7 +131,7 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -145,15 +142,13 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, 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) else: # make call to next link with the client's api-version @@ -164,14 +159,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -181,11 +175,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,5 +191,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py index c8d93d2e80ad..e84493117137 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, @@ -42,6 +41,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +97,6 @@ def list_for_resource( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -106,7 +108,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,7 +119,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -126,12 +128,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -142,14 +142,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -159,11 +158,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -193,7 +188,6 @@ def list_for_resource_group( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -205,7 +199,7 @@ def list_for_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,17 +210,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -237,14 +229,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -254,11 +245,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -271,10 +262,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace_async async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. @@ -283,12 +270,11 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,20 +288,18 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -327,14 +311,12 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def create( @@ -363,7 +345,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -374,7 +355,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -392,11 +373,10 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -407,7 +387,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. @@ -423,18 +403,14 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,23 +433,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -483,14 +457,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: @@ -500,12 +472,11 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -519,20 +490,18 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -542,14 +511,12 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: @@ -561,12 +528,11 @@ async def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Required. :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -580,19 +546,17 @@ async def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -604,14 +568,12 @@ async def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload async def create_by_id( @@ -635,7 +597,6 @@ async def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -643,7 +604,7 @@ async def create_by_id( @overload async def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. @@ -654,11 +615,10 @@ async def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -666,7 +626,10 @@ async def create_by_id( @distributed_trace_async async def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. @@ -677,18 +640,14 @@ async def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +670,20 @@ async def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,14 +693,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @distributed_trace_async async def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.RoleAssignment: @@ -755,12 +710,11 @@ async def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.Rol /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Required. :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -774,19 +728,17 @@ async def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.Rol api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -796,14 +748,12 @@ async def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: @@ -813,7 +763,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -825,7 +774,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,16 +785,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -856,14 +803,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -873,11 +819,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -890,8 +836,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any @@ -904,7 +848,6 @@ def list_for_scope( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -916,7 +859,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -927,16 +870,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -947,14 +888,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -964,11 +904,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -980,5 +920,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py index e53afe0a419e..f6d8530d357e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_definitions_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,12 +72,11 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,20 +90,18 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,14 +113,12 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -130,12 +128,11 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,20 +146,18 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -172,14 +167,12 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload async def create_or_update( @@ -202,7 +195,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -213,7 +205,7 @@ async def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -225,11 +217,10 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -237,7 +228,11 @@ async def create_or_update( @distributed_trace_async async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -246,17 +241,13 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -279,23 +270,21 @@ async def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -305,14 +294,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: @@ -323,7 +310,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] @@ -335,7 +321,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -346,16 +332,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -366,14 +350,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -383,11 +366,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -400,8 +383,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace_async async def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -412,12 +393,11 @@ async def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.Rol /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,19 +411,17 @@ async def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.Rol api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -453,11 +431,9 @@ async def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleDefinitionId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py index 6cb02fbd54fe..b784063ef0b1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py @@ -488,7 +488,7 @@ def __init__( class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar properties: Role assignment properties. Required. :vartype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties @@ -562,7 +562,7 @@ def __init__( class RoleAssignmentProperties(_serialization.Model): """Role assignment properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py index 2723b964e405..029bae977dba 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators 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 ClassicAdministrator or the result of cls(response) :rtype: @@ -99,7 +101,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,15 +112,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -129,14 +129,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) @@ -146,11 +145,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,5 +161,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py index 44e2996b346a..d01c45d1f3c1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -77,12 +80,11 @@ def __init__(self, *args, **kwargs): def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Elevates access for a Global Administrator. - :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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,18 +98,16 @@ def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_elevate_access_request( + _request = build_elevate_access_request( api_version=api_version, - template_url=self.elevate_access.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,6 +118,4 @@ def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - elevate_access.metadata = {"url": "/providers/Microsoft.Authorization/elevateAccess"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py index 947f26d65d70..5e9185386ecf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_for_resource_group_request(resource_group_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +100,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,7 +138,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It :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 Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: @@ -146,7 +148,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -157,16 +159,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -177,14 +177,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -194,11 +193,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,10 +210,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -238,7 +233,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: @@ -249,7 +243,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,7 +254,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -268,12 +262,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -284,14 +276,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -301,11 +292,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -317,7 +308,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py index 227deda6a6df..590a9059f271 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_request(resource_provider_namespace: str, *, expand: str = "resour "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -115,12 +118,11 @@ def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -134,20 +136,18 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -157,14 +157,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_models.ProviderOperationsMetadata"]: @@ -172,7 +170,6 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :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 ProviderOperationsMetadata or the result of cls(response) :rtype: @@ -185,7 +182,7 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -196,15 +193,13 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, 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) else: # make call to next link with the client's api-version @@ -215,14 +210,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -232,11 +226,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -248,5 +242,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py index f84bbdb3cb5c..ad8f42ecdfa7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +73,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -104,7 +107,7 @@ def build_list_for_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -131,7 +134,7 @@ def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,7 +160,7 @@ def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +187,7 @@ def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> H "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,7 +211,7 @@ def build_delete_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRe "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -233,7 +236,7 @@ def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRe "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -259,7 +262,7 @@ def build_get_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpReque "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -285,7 +288,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -311,7 +314,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -372,7 +375,6 @@ def list_for_resource( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -384,7 +386,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,7 +397,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -404,12 +406,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -420,14 +420,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -437,11 +436,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -454,10 +453,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -471,7 +466,6 @@ def list_for_resource_group( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -483,7 +477,7 @@ def list_for_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -494,17 +488,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -515,14 +507,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -532,11 +523,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -549,10 +540,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. @@ -561,12 +548,11 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -580,20 +566,18 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -605,14 +589,12 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def create( @@ -641,7 +623,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -652,7 +633,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -670,11 +651,10 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -685,7 +665,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. @@ -701,18 +681,14 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -735,23 +711,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -761,14 +735,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: @@ -778,12 +750,11 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -797,20 +768,18 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -820,14 +789,12 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: @@ -839,12 +806,11 @@ def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional[_mode /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Required. :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -858,19 +824,17 @@ def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional[_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -882,14 +846,12 @@ def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional[_mode deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload def create_by_id( @@ -913,7 +875,6 @@ def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -921,7 +882,7 @@ def create_by_id( @overload def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. @@ -932,11 +893,10 @@ def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -944,7 +904,10 @@ def create_by_id( @distributed_trace def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. @@ -955,18 +918,14 @@ def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -989,22 +948,20 @@ def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1014,14 +971,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @distributed_trace def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.RoleAssignment: @@ -1033,12 +988,11 @@ def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.RoleAssig /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Required. :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1052,19 +1006,17 @@ def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.RoleAssig api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1074,14 +1026,12 @@ def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.RoleAssig error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: @@ -1091,7 +1041,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -1103,7 +1052,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1114,16 +1063,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1134,14 +1081,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1151,11 +1097,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1168,8 +1114,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any @@ -1182,7 +1126,6 @@ def list_for_scope( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] @@ -1194,7 +1137,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1205,16 +1148,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1225,14 +1166,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1242,11 +1182,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1258,5 +1198,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py index 209215e725ac..b2ebcb778743 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +79,7 @@ def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> Htt "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +105,7 @@ def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +131,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -154,7 +157,7 @@ def build_get_by_id_request(role_definition_id: str, **kwargs: Any) -> HttpReque "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,12 +196,11 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,20 +214,18 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -237,14 +237,12 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -254,12 +252,11 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -273,20 +270,18 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -296,14 +291,12 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload def create_or_update( @@ -326,7 +319,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -337,7 +329,7 @@ def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -349,11 +341,10 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -361,7 +352,11 @@ def create_or_update( @distributed_trace def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -370,17 +365,13 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,23 +394,21 @@ def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,14 +418,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: @@ -447,7 +434,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] @@ -459,7 +445,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,16 +456,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -490,14 +474,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -507,11 +490,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -524,8 +507,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -536,12 +517,11 @@ def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.RoleDefin /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -555,19 +535,17 @@ def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.RoleDefin api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,11 +555,9 @@ def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.RoleDefin error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleDefinitionId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py index 5ad48e5dacbd..f52db14e607c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -64,7 +67,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -83,7 +104,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -103,12 +124,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py index 3a5e01a9072a..7b13deb537bd 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-01-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json index 9a806fbd35d2..1e4ff21d6f0f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "provider_operations_metadata": "ProviderOperationsMetadataOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py index 3925e922add3..9d32bb475133 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -64,7 +67,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -83,7 +104,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -103,12 +126,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py index b2152db43266..a2e1f8b8b37b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-01-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py index 6e00acd23c6b..6977025c4393 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +63,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As :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 Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] @@ -74,7 +76,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,16 +87,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -105,14 +105,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -122,11 +121,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -139,10 +138,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -166,7 +161,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] @@ -180,7 +174,7 @@ def list_for_resource( ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,7 +185,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -199,12 +193,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -215,14 +207,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -232,11 +223,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -248,7 +239,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py index 496995dc7849..574b5495c97d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._provider_operations_metadata_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,12 +67,11 @@ async def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,20 +87,18 @@ async def get( ) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,14 +108,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_models.ProviderOperationsMetadata"]: @@ -123,7 +121,6 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :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 ProviderOperationsMetadata or the result of cls(response) :rtype: @@ -138,7 +135,7 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ ) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,15 +146,13 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, 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) else: # make call to next link with the client's api-version @@ -168,14 +163,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -185,11 +179,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,5 +195,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py index 8f68827c9436..89bfb796c9b2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, @@ -42,6 +41,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +97,6 @@ def list_for_resource( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -108,7 +110,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,7 +121,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -128,12 +130,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -144,14 +144,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -161,11 +160,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -178,10 +177,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -195,7 +190,6 @@ def list_for_resource_group( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -209,7 +203,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,17 +214,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -241,14 +233,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -258,11 +249,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -275,10 +266,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace_async async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. @@ -287,12 +274,11 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,20 +294,18 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -333,14 +317,12 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def create( @@ -370,7 +352,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -381,7 +362,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -399,11 +380,10 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -414,7 +394,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. @@ -430,18 +410,15 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,23 +443,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,14 +467,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: @@ -509,12 +482,11 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,20 +502,18 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,14 +523,12 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: @@ -568,12 +536,11 @@ async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.Ro :param role_id: The ID of the role assignment to delete. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,19 +556,17 @@ async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.Ro ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_id=role_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -613,14 +578,12 @@ async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.Ro deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @overload async def create_by_id( @@ -641,7 +604,6 @@ async def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -649,18 +611,17 @@ async def create_by_id( @overload async def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -668,25 +629,22 @@ async def create_by_id( @distributed_trace_async async def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +669,20 @@ async def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,14 +692,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: @@ -751,12 +705,11 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment :param role_id: The ID of the role assignment to get. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -772,19 +725,17 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -794,14 +745,12 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: @@ -811,7 +760,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -825,7 +773,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,16 +784,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -856,14 +802,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -873,11 +818,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -890,8 +835,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any @@ -904,7 +847,6 @@ def list_for_scope( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -918,7 +860,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -929,16 +871,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -949,14 +889,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -966,11 +905,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -982,5 +921,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py index d90764340cff..f9a9baf7d769 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_definitions_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,12 +72,11 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,20 +92,18 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,14 +115,12 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -132,12 +130,11 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,20 +150,18 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,14 +171,12 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload async def create_or_update( @@ -206,7 +199,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -217,7 +209,7 @@ async def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -229,11 +221,10 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -241,7 +232,11 @@ async def create_or_update( @distributed_trace_async async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -250,18 +245,14 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. + a IO[bytes] type. Required. :type role_definition: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,23 +277,21 @@ async def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -312,14 +301,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: @@ -330,7 +317,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] @@ -344,7 +330,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -355,16 +341,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -375,14 +359,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -392,11 +375,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -409,8 +392,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -421,12 +402,11 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,19 +422,17 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -464,11 +442,9 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py index 03998151c3c9..96753d916170 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py @@ -458,7 +458,7 @@ def __init__( class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py index ec916a24c3f5..6cab6ed23125 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_for_resource_group_request(resource_group_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +102,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,7 +140,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It :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 Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] @@ -151,7 +153,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,16 +164,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -182,14 +182,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -199,11 +198,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,10 +215,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -243,7 +238,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] @@ -257,7 +251,7 @@ def list_for_resource( ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -268,7 +262,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -276,12 +270,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -292,14 +284,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -309,11 +300,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -325,7 +316,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py index c447ad8b13c5..b03f3a637dc4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_get_request(resource_provider_namespace: str, *, expand: str = "resour ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,12 +120,11 @@ def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -138,20 +140,18 @@ def get( ) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -161,14 +161,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_models.ProviderOperationsMetadata"]: @@ -176,7 +174,6 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :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 ProviderOperationsMetadata or the result of cls(response) :rtype: @@ -191,7 +188,7 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model ) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -202,15 +199,13 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, 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) else: # make call to next link with the client's api-version @@ -221,14 +216,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -238,11 +232,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,5 +248,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py index 455091767542..ef5cb033b2d8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +75,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -106,7 +109,7 @@ def build_list_for_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -133,7 +136,7 @@ def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,7 +162,7 @@ def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,7 +189,7 @@ def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> H "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,7 +213,7 @@ def build_delete_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -235,7 +238,7 @@ def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -261,7 +264,7 @@ def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -287,7 +290,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -313,7 +316,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -374,7 +377,6 @@ def list_for_resource( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -388,7 +390,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +401,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -408,12 +410,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -424,14 +424,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -441,11 +440,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,10 +457,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -475,7 +470,6 @@ def list_for_resource_group( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -489,7 +483,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,17 +494,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -521,14 +513,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -538,11 +529,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -555,10 +546,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. @@ -567,12 +554,11 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,20 +574,18 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -613,14 +597,12 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def create( @@ -650,7 +632,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +642,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -679,11 +660,10 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -694,7 +674,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. @@ -710,18 +690,15 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -746,23 +723,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -772,14 +747,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: @@ -789,12 +762,11 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -810,20 +782,18 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -833,14 +803,12 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: @@ -848,12 +816,11 @@ def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssi :param role_id: The ID of the role assignment to delete. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -869,19 +836,17 @@ def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssi ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_id=role_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -893,14 +858,12 @@ def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssi deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @overload def create_by_id( @@ -921,7 +884,6 @@ def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -929,18 +891,17 @@ def create_by_id( @overload def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -948,25 +909,22 @@ def create_by_id( @distributed_trace def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -991,22 +949,20 @@ def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1016,14 +972,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: @@ -1031,12 +985,11 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: :param role_id: The ID of the role assignment to get. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1052,19 +1005,17 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1074,14 +1025,12 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: @@ -1091,7 +1040,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -1105,7 +1053,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1116,16 +1064,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1136,14 +1082,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1153,11 +1098,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1170,8 +1115,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any @@ -1184,7 +1127,6 @@ def list_for_scope( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] @@ -1198,7 +1140,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1209,16 +1151,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1229,14 +1169,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1246,11 +1185,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1262,5 +1201,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py index ac7d84073fdb..7db38d58145a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +79,7 @@ def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> Htt "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +105,7 @@ def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +131,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -154,7 +157,7 @@ def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,12 +196,11 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -214,20 +216,18 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -239,14 +239,12 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -256,12 +254,11 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,20 +274,18 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -300,14 +295,12 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload def create_or_update( @@ -330,7 +323,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -341,7 +333,7 @@ def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -353,11 +345,10 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -365,7 +356,11 @@ def create_or_update( @distributed_trace def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -374,18 +369,14 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. + a IO[bytes] type. Required. :type role_definition: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,23 +401,21 @@ def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -436,14 +425,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: @@ -454,7 +441,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] @@ -468,7 +454,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -479,16 +465,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -499,14 +483,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -516,11 +499,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -533,8 +516,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -545,12 +526,11 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,19 +546,17 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -588,11 +566,9 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py index e80e2c8a5e3c..0e847379a6ca 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -85,7 +88,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -121,7 +142,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -141,12 +162,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py index 676d7f01a754..42eea5a895d9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json index aefc25530dbf..f156863d3740 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py index 0d346caa3a09..d71851b22dfa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -85,7 +88,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -121,7 +142,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -141,12 +164,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py index 11425fcc1e0e..cf896b80ab1b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py index 4093f9122e0d..c550d3a2091d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._access_review_default_settings_operations import build_get_request, build_put_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,12 +59,11 @@ def __init__(self, *args, **kwargs) -> None: async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -77,19 +79,17 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -99,16 +99,12 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload async def put( @@ -122,7 +118,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -130,16 +125,15 @@ async def put( @overload async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -147,23 +141,19 @@ async def put( @distributed_trace_async async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +178,20 @@ async def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,13 +201,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py index 73ed017371b3..6964bca02143 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_decisions_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +66,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: @@ -78,7 +80,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,17 +91,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,14 +110,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -127,11 +126,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,7 +142,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py index ab73f5220fa7..399414bef430 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,26 +21,28 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -69,7 +72,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: @@ -84,7 +86,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,16 +97,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -115,14 +115,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -132,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,10 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -165,12 +160,11 @@ async def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,21 +180,19 @@ async def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +202,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload async def patch( @@ -246,7 +234,6 @@ async def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -258,7 +245,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -272,11 +259,10 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -288,7 +274,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -300,18 +286,15 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,7 +319,7 @@ async def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -344,16 +327,14 @@ async def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,13 +344,9 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py index f48d95fd5364..5a63cc05f010 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, @@ -33,6 +32,10 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,12 +70,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +90,19 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,11 +113,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -129,12 +125,11 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -150,21 +145,19 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,11 +168,7 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -191,12 +180,11 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,21 +200,19 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -237,11 +223,7 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements @@ -253,12 +235,11 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,21 +255,19 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,11 +278,7 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -315,12 +290,11 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,20 +310,18 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +332,4 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py index 851f3ad97599..52d5527286c2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,25 +20,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instances_assigned_for_my_approval_operations import ( build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -63,7 +66,6 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_mo :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: @@ -78,7 +80,7 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_mo ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,15 +91,13 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -108,14 +108,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -125,11 +124,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,10 +141,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -154,12 +149,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,20 +169,18 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,13 +190,9 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py index 486b19bc7043..11e8342f032b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._access_review_instances_operations import build_get_by_id_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +63,6 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_mo :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: @@ -75,7 +77,7 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_mo ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,16 +88,14 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -106,14 +106,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -123,11 +122,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -140,10 +139,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -152,12 +147,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,21 +167,19 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,13 +189,9 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index efcd59d346a3..a3a7cf4a6003 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -72,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefi ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,14 +85,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefi def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -101,14 +101,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -118,11 +117,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py index 8a2c955b98db..9d8dd28918a6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, @@ -37,11 +36,15 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -65,7 +68,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -80,7 +82,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefi ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,15 +93,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefi def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,14 +110,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -127,11 +126,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,22 +143,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,20 +169,18 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,16 +190,12 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -217,12 +205,11 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,20 +225,18 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,11 +247,7 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update_by_id( @@ -287,7 +268,6 @@ async def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -295,18 +275,22 @@ async def create_or_update_by_id( @overload async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -316,7 +300,7 @@ async def create_or_update_by_id( async def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -324,19 +308,15 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -361,23 +341,21 @@ async def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,16 +365,12 @@ async def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -406,12 +380,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -427,20 +400,18 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -451,8 +422,4 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py index 70974ee792c4..7aad8c57dfd9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2018_05_01_preview.models.Operation] @@ -71,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +84,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -100,14 +100,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _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) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py index 1440b3c8986f..d84a3cb06530 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py @@ -326,7 +326,7 @@ class AccessReviewDecisionTarget(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: ServicePrincipalDecisionTarget, UserDecisionTarget - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -1535,7 +1535,7 @@ class ServicePrincipalDecisionTarget(AccessReviewDecisionTarget): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -1576,7 +1576,7 @@ class UserDecisionTarget(AccessReviewDecisionTarget): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py index 5eb5975a1621..bafec7996509 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,12 +119,11 @@ def __init__(self, *args, **kwargs): def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,19 +139,17 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,16 +159,12 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload def put( @@ -182,7 +178,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -190,16 +185,15 @@ def put( @overload def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -207,23 +201,19 @@ def put( @distributed_trace def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,22 +238,20 @@ def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +261,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py index 1c86e8c0737f..8fbfa00ce432 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_list_request(schedule_definition_id: str, id: str, subscription_id: st "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +96,6 @@ def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable[ :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: @@ -108,7 +110,7 @@ def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable[ ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,17 +121,15 @@ def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable[ def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -140,14 +140,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -157,11 +156,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +172,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py index b2b8dae079ef..9e2c3a201b32 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> H "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: s "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +116,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +129,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -154,7 +157,6 @@ def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable[ :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: @@ -169,7 +171,7 @@ def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable[ ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -180,16 +182,14 @@ def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable[ def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -200,14 +200,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -217,11 +216,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -234,10 +233,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -250,12 +245,11 @@ def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,21 +265,19 @@ def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -295,16 +287,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload def patch( @@ -331,7 +319,6 @@ def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -343,7 +330,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -357,11 +344,10 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -373,7 +359,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -385,18 +371,15 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,7 +404,7 @@ def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -429,16 +412,14 @@ def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -448,13 +429,9 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py index 1b5d7c5a7588..87c2d87095d1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_stop_request(schedule_definition_id: str, id: str, subscription_id: st "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_reset_decisions_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +117,7 @@ def build_apply_decisions_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +148,7 @@ def build_send_reminders_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +176,7 @@ def build_accept_recommendations_request(schedule_definition_id: str, id: str, * "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,12 +217,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -235,21 +237,19 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,11 +260,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -276,12 +272,11 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,21 +292,19 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -322,11 +315,7 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -338,12 +327,11 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,21 +347,19 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,11 +370,7 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements @@ -400,12 +382,11 @@ def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,21 +402,19 @@ def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,11 +425,7 @@ def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -462,12 +437,11 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,20 +457,18 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,8 +479,4 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py index 4f262f516dfa..a162eace064b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_request(schedule_definition_id: str, **kwargs: Any) -> HttpReques "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +83,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +94,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -117,7 +120,6 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: @@ -132,7 +134,7 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models. ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -143,15 +145,13 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models. def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -162,14 +162,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -179,11 +178,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,10 +195,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -208,12 +203,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,20 +223,18 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -252,13 +244,9 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py index e944e31089c8..21026c068264 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(schedule_definition_id: str, subscription_id: str, **kwar "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +85,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_i "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -119,7 +122,6 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: @@ -134,7 +136,7 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models. ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -145,16 +147,14 @@ def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models. def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -165,14 +165,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -182,11 +181,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,10 +198,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -211,12 +206,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -232,21 +226,19 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -256,13 +248,9 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index ebc0067a2fd3..14ab0895bb4e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -79,7 +82,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -94,7 +96,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinitio ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,14 +107,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinitio def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -123,14 +123,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -140,11 +139,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -156,5 +155,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py index f426bc61978c..fc49eb8fcf64 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +84,7 @@ def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, * "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,7 +112,7 @@ def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +143,7 @@ def build_create_or_update_by_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -170,7 +173,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -181,7 +184,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -205,7 +208,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -220,7 +222,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinitio ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,15 +233,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinitio def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -250,14 +250,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -267,11 +266,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,22 +283,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -315,20 +309,18 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -338,16 +330,12 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -357,12 +345,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -378,20 +365,18 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -402,11 +387,7 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update_by_id( @@ -427,7 +408,6 @@ def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -435,18 +415,22 @@ def create_or_update_by_id( @overload def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -456,7 +440,7 @@ def create_or_update_by_id( def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -464,19 +448,15 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,23 +481,21 @@ def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -527,16 +505,12 @@ def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -546,12 +520,11 @@ def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -567,20 +540,18 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -591,8 +562,4 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py index d924a02a47bb..a981d5076b2e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +82,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2018_05_01_preview.models.Operation] @@ -93,7 +95,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,14 +106,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -122,14 +122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -139,11 +138,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py index 7975dfdc77be..df0c149f8f43 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -62,7 +83,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -82,12 +103,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py index 284188d97bca..4ba2032fbc90 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json index 92e1896abe79..6bf3dc59c75b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deny_assignments": "DenyAssignmentsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py index 0ebc0b77e131..162af9f91508 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -62,7 +83,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -82,12 +105,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py index c302fa6a1cab..906fca032e08 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py index ff430ddfd414..f8be181547e7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._deny_assignments_operations import ( build_get_by_id_request, build_get_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -96,7 +99,6 @@ def list_for_resource( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -110,7 +112,7 @@ def list_for_resource( ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +123,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -130,12 +132,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -146,14 +146,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -163,11 +162,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -180,10 +179,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -204,7 +199,6 @@ def list_for_resource_group( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -218,7 +212,7 @@ def list_for_resource_group( ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,17 +223,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -250,14 +242,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -267,11 +258,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,10 +275,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. @@ -303,7 +290,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -317,7 +303,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -328,16 +314,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -348,14 +332,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -365,11 +348,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -382,8 +365,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - @distributed_trace_async async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. @@ -392,12 +373,11 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -413,20 +393,18 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -436,14 +414,12 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace_async async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: @@ -455,12 +431,11 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -476,19 +451,17 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -498,14 +471,12 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -526,7 +497,6 @@ def list_for_scope( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -540,7 +510,7 @@ def list_for_scope( ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -551,16 +521,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -571,14 +539,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -588,11 +555,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -604,5 +571,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py index 7549851ad47d..6a3319ef8487 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,7 @@ def build_list_for_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,7 +108,7 @@ def build_list_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,7 +136,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,7 +163,7 @@ def build_get_request(scope: str, deny_assignment_id: str, **kwargs: Any) -> Htt "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +187,7 @@ def build_get_by_id_request(deny_assignment_id: str, **kwargs: Any) -> HttpReque "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,7 +211,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,7 +279,6 @@ def list_for_resource( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -290,7 +292,7 @@ def list_for_resource( ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -301,7 +303,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -310,12 +312,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -326,14 +326,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -343,11 +342,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,10 +359,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -384,7 +379,6 @@ def list_for_resource_group( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -398,7 +392,7 @@ def list_for_resource_group( ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,17 +403,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -430,14 +422,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -447,11 +438,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -464,10 +455,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. @@ -483,7 +470,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -497,7 +483,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,16 +494,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -528,14 +512,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -545,11 +528,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -562,8 +545,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - @distributed_trace def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. @@ -572,12 +553,11 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -593,20 +573,18 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -616,14 +594,12 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: @@ -635,12 +611,11 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,19 +631,17 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -678,14 +651,12 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -706,7 +677,6 @@ def list_for_scope( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] @@ -720,7 +690,7 @@ def list_for_scope( ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -731,16 +701,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -751,14 +719,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -768,11 +735,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -784,5 +751,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py index e62641a6e5bf..87fb7c37f57e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -51,7 +54,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -61,7 +82,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,12 +102,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py index 863895fcb33f..516b08ebd3bf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-09-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json index a6c48bf89a75..f49ae1d2ba55 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignments": "RoleAssignmentsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py index a9c7a08d8f5e..9da5cbd93a7b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -51,7 +54,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -61,7 +82,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,12 +104,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py index 8841ae1b0d47..01740dac0dd9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-09-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py index 1b10589d163f..72334dcf115e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, @@ -42,6 +41,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +97,6 @@ def list_for_resource( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -108,7 +110,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,7 +121,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -128,12 +130,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -144,14 +144,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -161,11 +160,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -178,10 +177,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -195,7 +190,6 @@ def list_for_resource_group( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -209,7 +203,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,17 +214,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -241,14 +233,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -258,11 +249,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -275,10 +266,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace_async async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. @@ -287,12 +274,11 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,20 +294,18 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -333,14 +317,12 @@ async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def create( @@ -370,7 +352,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -381,7 +362,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -399,11 +380,10 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -414,7 +394,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. @@ -430,18 +410,15 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,23 +443,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,14 +467,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: @@ -509,12 +482,11 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,20 +502,18 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,14 +523,12 @@ async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: @@ -568,12 +536,11 @@ async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.Ro :param role_id: The ID of the role assignment to delete. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,19 +556,17 @@ async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.Ro ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_id=role_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -613,14 +578,12 @@ async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.Ro deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @overload async def create_by_id( @@ -641,7 +604,6 @@ async def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -649,18 +611,17 @@ async def create_by_id( @overload async def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -668,25 +629,22 @@ async def create_by_id( @distributed_trace_async async def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +669,20 @@ async def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,14 +692,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: @@ -751,12 +705,11 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment :param role_id: The ID of the role assignment to get. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -772,19 +725,17 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -794,14 +745,12 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: @@ -811,7 +760,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -825,7 +773,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,16 +784,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -856,14 +802,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -873,11 +818,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -890,8 +835,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any @@ -904,7 +847,6 @@ def list_for_scope( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -918,7 +860,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -929,16 +871,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -949,14 +889,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -966,11 +905,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -982,5 +921,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py index ab4f4604c7cd..5e06476c4a25 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py @@ -189,7 +189,7 @@ def __init__( class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py index 36aeaa1c57e6..4c6f6a56eb0e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +75,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -106,7 +109,7 @@ def build_list_for_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -133,7 +136,7 @@ def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,7 +162,7 @@ def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,7 +189,7 @@ def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> H "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,7 +213,7 @@ def build_delete_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -235,7 +238,7 @@ def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -261,7 +264,7 @@ def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -287,7 +290,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -313,7 +316,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -374,7 +377,6 @@ def list_for_resource( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -388,7 +390,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +401,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -408,12 +410,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -424,14 +424,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -441,11 +440,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,10 +457,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -475,7 +470,6 @@ def list_for_resource_group( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -489,7 +483,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,17 +494,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -521,14 +513,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -538,11 +529,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -555,10 +546,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. @@ -567,12 +554,11 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,20 +574,18 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -613,14 +597,12 @@ def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Option deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def create( @@ -650,7 +632,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +642,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -679,11 +660,10 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -694,7 +674,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. @@ -710,18 +690,15 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -746,23 +723,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -772,14 +747,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: @@ -789,12 +762,11 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -810,20 +782,18 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -833,14 +803,12 @@ def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.R error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: @@ -848,12 +816,11 @@ def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssi :param role_id: The ID of the role assignment to delete. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -869,19 +836,17 @@ def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssi ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_id=role_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -893,14 +858,12 @@ def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssi deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @overload def create_by_id( @@ -921,7 +884,6 @@ def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -929,18 +891,17 @@ def create_by_id( @overload def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -948,25 +909,22 @@ def create_by_id( @distributed_trace def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -991,22 +949,20 @@ def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1016,14 +972,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: @@ -1031,12 +985,11 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: :param role_id: The ID of the role assignment to get. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1052,19 +1005,17 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1074,14 +1025,12 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: @@ -1091,7 +1040,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -1105,7 +1053,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1116,16 +1064,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1136,14 +1082,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1153,11 +1098,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1170,8 +1115,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any @@ -1184,7 +1127,6 @@ def list_for_scope( assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] @@ -1198,7 +1140,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1209,16 +1151,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1229,14 +1169,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1246,11 +1185,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1262,5 +1201,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py index deb75cdee38b..e9d67e4ff4b2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -51,7 +54,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -61,7 +82,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,12 +102,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py index e4a18fcf0fa3..fa8880fe869c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-08-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json index 935618b6c875..3f78abcbdcf2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignment_metrics": "RoleAssignmentMetricsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py index e68025f85285..a4bbfe53fdb4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -51,7 +54,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -61,7 +82,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,12 +104,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py index 66d50b07bc2a..52825bc0a5c0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-08-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py index 8fde64168d76..5f05defe9977 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_metrics_operations import build_get_metrics_for_subscription_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,12 +58,11 @@ def __init__(self, *args, **kwargs) -> None: async def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: """Get role assignment usage metrics for a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentMetricsResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -76,19 +78,17 @@ async def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssig ) cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) - request = build_get_metrics_for_subscription_request( + _request = build_get_metrics_for_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_metrics_for_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -98,13 +98,9 @@ async def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssig error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) + deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_metrics_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py index 41ab3da09a46..1a5013e93402 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -34,7 +37,9 @@ _SERIALIZER.client_side_validation = False -def build_get_metrics_for_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_metrics_for_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -49,7 +54,7 @@ def build_get_metrics_for_subscription_request(subscription_id: str, **kwargs: A "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,12 +89,11 @@ def __init__(self, *args, **kwargs): def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: """Get role assignment usage metrics for a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentMetricsResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,19 +109,17 @@ def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentM ) cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) - request = build_get_metrics_for_subscription_request( + _request = build_get_metrics_for_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_metrics_for_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,13 +129,9 @@ def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentM error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) + deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_metrics_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py index 3cdc34f3a2c0..5ec79c76e521 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -51,7 +54,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -61,7 +82,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,12 +102,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py index 80f427785333..42a599807555 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-04-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json index 6ff2f6e79701..20bc5e300e11 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignments": "RoleAssignmentsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py index d2be59ccf08a..fe66c8b72230 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -51,7 +54,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -61,7 +82,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,12 +104,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py index 741cb552215b..2a09c7490d3e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-04-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py index 83d7ed40c526..f2a42c4e91e7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, @@ -42,6 +41,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +100,6 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -111,7 +113,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -122,7 +124,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -132,12 +134,10 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -148,14 +148,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -165,11 +164,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,10 +181,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -201,7 +196,6 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -215,7 +209,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,18 +220,16 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -248,14 +240,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -265,11 +256,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -282,10 +273,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -298,12 +285,11 @@ async def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -319,21 +305,19 @@ async def delete( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -345,14 +329,12 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def create( @@ -382,7 +364,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -393,7 +374,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -411,11 +392,10 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -426,7 +406,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. @@ -442,18 +422,15 @@ async def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,23 +455,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -504,14 +479,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def get( @@ -525,12 +498,11 @@ async def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,21 +518,19 @@ async def get( ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -570,14 +540,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( @@ -589,12 +557,11 @@ async def delete_by_id( :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -610,20 +577,18 @@ async def delete_by_id( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -635,14 +600,12 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @overload async def create_by_id( @@ -663,7 +626,6 @@ async def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -671,18 +633,17 @@ async def create_by_id( @overload async def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -690,25 +651,22 @@ async def create_by_id( @distributed_trace_async async def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -733,22 +691,20 @@ async def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -758,14 +714,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace_async async def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: @@ -775,12 +729,11 @@ async def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwarg :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -796,20 +749,18 @@ async def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwarg ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_id, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -819,14 +770,12 @@ async def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwarg error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def list( @@ -840,7 +789,6 @@ def list( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -854,7 +802,7 @@ def list( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,17 +813,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -886,14 +832,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -903,11 +848,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -920,8 +865,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -936,7 +879,6 @@ def list_for_scope( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -950,7 +892,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -961,17 +903,15 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -982,14 +922,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -999,11 +938,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1015,5 +954,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py index 805b0304cbb9..75bba1265330 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py @@ -255,7 +255,7 @@ def __init__( class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py index 709edb7a0bea..d967f2dba01e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +76,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -114,7 +117,7 @@ def build_list_for_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -145,7 +148,7 @@ def build_delete_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +176,7 @@ def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +205,7 @@ def build_get_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -228,7 +231,7 @@ def build_delete_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -255,7 +258,7 @@ def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -281,7 +284,7 @@ def build_get_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, ** "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -311,7 +314,7 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -341,7 +344,7 @@ def build_list_for_scope_request( "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -407,7 +410,6 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -421,7 +423,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,7 +434,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -442,12 +444,10 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -458,14 +458,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -475,11 +474,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,10 +491,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -511,7 +506,6 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -525,7 +519,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -536,18 +530,16 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -558,14 +550,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -575,11 +566,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -592,10 +583,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -608,12 +595,11 @@ def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -629,21 +615,19 @@ def delete( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -655,14 +639,12 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def create( @@ -692,7 +674,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -703,7 +684,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -721,11 +702,10 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -736,7 +716,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. @@ -752,18 +732,15 @@ def create( and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,23 +765,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -814,14 +789,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def get( @@ -835,12 +808,11 @@ def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -856,21 +828,19 @@ def get( ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -880,14 +850,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def delete_by_id( @@ -899,12 +867,11 @@ def delete_by_id( :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -920,20 +887,18 @@ def delete_by_id( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -945,14 +910,12 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @overload def create_by_id( @@ -973,7 +936,6 @@ def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -981,18 +943,17 @@ def create_by_id( @overload def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -1000,25 +961,22 @@ def create_by_id( @distributed_trace def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1043,22 +1001,20 @@ def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1068,14 +1024,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: @@ -1085,12 +1039,11 @@ def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,20 +1059,18 @@ def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_id, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1129,14 +1080,12 @@ def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore @distributed_trace def list( @@ -1150,7 +1099,6 @@ def list( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -1164,7 +1112,7 @@ def list( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1175,17 +1123,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1196,14 +1142,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1213,11 +1158,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1230,8 +1175,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -1246,7 +1189,6 @@ def list_for_scope( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] @@ -1260,7 +1202,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1271,17 +1213,15 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1292,14 +1232,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1309,11 +1248,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1325,5 +1264,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py index 639e414d454d..e278347f28be 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -78,7 +81,25 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -112,7 +133,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-10-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -132,12 +153,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py index aea735ace4db..f29f6253e3b3 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json index 29397fd61b07..6187d0bf01a5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -88,8 +88,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "eligible_child_resources": "EligibleChildResourcesOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py index 78cdb17387c6..199c22c93a98 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -78,7 +81,25 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -112,7 +133,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-10-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -132,12 +155,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py index 28344f73847e..edcca77ffc93 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py index 474a0ebb9741..633d4577c74b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._eligible_child_resources_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +69,6 @@ def get( $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. 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 EligibleChildResource or the result of cls(response) :rtype: @@ -79,7 +81,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,16 +92,14 @@ def get( def prepare_request(next_link=None): if not next_link: - request = build_get_request( + _request = build_get_request( scope=scope, filter=filter, 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) else: # make call to next link with the client's api-version @@ -110,14 +110,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) @@ -127,11 +126,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,5 +141,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py index ebcb4e78ea7f..bce6a83d9884 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,22 +20,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleAssignmentScheduleInstancesOperations: +class RoleAssignmentScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -69,7 +72,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedule instances created for the current user. 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 RoleAssignmentScheduleInstance or the result of cls(response) :rtype: @@ -82,7 +84,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,16 +95,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -113,14 +113,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) @@ -130,11 +129,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,8 +145,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any @@ -159,12 +156,11 @@ async def get( :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,20 +174,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -200,13 +194,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py index 0ae5c5d9a086..036b8c7c40d4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -37,6 +36,10 @@ build_validate_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -88,7 +91,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -99,7 +101,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -117,11 +119,10 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -132,7 +133,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -148,18 +149,14 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -182,23 +179,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,16 +202,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -229,12 +220,11 @@ async def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,20 +238,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,16 +258,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -297,7 +281,6 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. 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 RoleAssignmentScheduleRequest or the result of cls(response) :rtype: @@ -310,7 +293,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,16 +304,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -341,14 +322,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -358,11 +338,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -374,8 +354,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any @@ -387,12 +365,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,20 +383,18 @@ async def cancel( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,11 +404,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def validate( @@ -457,7 +428,6 @@ async def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +438,7 @@ async def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -481,11 +451,10 @@ async def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -496,7 +465,7 @@ async def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Validates a new role assignment schedule request. @@ -507,18 +476,14 @@ async def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,23 +506,21 @@ async def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -566,13 +529,9 @@ async def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py index b3250239af59..fa18fae76e89 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._role_assignment_schedules_operations import build_get_request, build_list_for_scope_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,12 +68,11 @@ async def get( :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,20 +86,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,16 +106,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) + deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -132,7 +128,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. 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 RoleAssignmentSchedule or the result of cls(response) :rtype: @@ -145,7 +140,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,16 +151,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -176,14 +169,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) @@ -193,11 +185,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,5 +200,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py index dab77c986c6a..8dbee37237e3 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,25 +20,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_instances_operations import ( build_get_request, build_list_for_scope_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleEligibilityScheduleInstancesOperations: +class RoleEligibilityScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +75,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilityScheduleInstance or the result of cls(response) :rtype: @@ -85,7 +87,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,16 +98,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) @@ -133,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,8 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any @@ -162,12 +159,11 @@ async def get( :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,20 +177,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -203,13 +197,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py index 384a66bed66e..a5c4343713ab 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -37,11 +36,15 @@ build_validate_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -88,7 +91,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -99,7 +101,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -117,11 +119,10 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -132,7 +133,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -148,18 +149,14 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -182,23 +179,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,16 +202,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -229,12 +220,11 @@ async def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,20 +238,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,16 +258,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -297,7 +281,6 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. 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 RoleEligibilityScheduleRequest or the result of cls(response) :rtype: @@ -310,7 +293,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,16 +304,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -341,14 +322,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -358,11 +338,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -374,8 +354,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any @@ -387,12 +365,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,20 +383,18 @@ async def cancel( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,11 +404,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def validate( @@ -457,7 +428,6 @@ async def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +438,7 @@ async def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -481,11 +451,10 @@ async def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -496,7 +465,7 @@ async def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Validates a new role eligibility schedule request. @@ -507,18 +476,14 @@ async def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,23 +506,21 @@ async def validate( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -566,13 +529,9 @@ async def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py index beeb9ff0e6db..9a2aba7eea1d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._role_eligibility_schedules_operations import build_get_request, build_list_for_scope_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,12 +68,11 @@ async def get( :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,20 +86,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,16 +106,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) + deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -132,7 +128,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilitySchedule or the result of cls(response) :rtype: @@ -145,7 +140,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,16 +151,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -176,14 +169,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) @@ -193,11 +185,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,5 +200,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py index 24d48258e4e8..36e1b31bde08 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_management_policies_operations import ( build_delete_request, build_get_request, @@ -36,6 +35,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,12 +72,11 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,20 +90,18 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,16 +110,12 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @overload async def update( @@ -143,7 +139,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -154,7 +149,7 @@ async def update( self, scope: str, role_management_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -167,11 +162,10 @@ async def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -182,7 +176,7 @@ async def update( self, scope: str, role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], + parameters: Union[_models.RoleManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. @@ -193,17 +187,14 @@ async def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy or + IO[bytes] :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,23 +217,21 @@ async def update( else: _json = self._serialize.body(parameters, "RoleManagementPolicy") - request = build_update_request( + _request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,16 +240,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -273,12 +258,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,20 +276,18 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -315,11 +297,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicy"]: @@ -327,7 +305,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: @@ -340,7 +317,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -351,15 +328,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -370,14 +345,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) @@ -387,11 +361,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -402,5 +376,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py index c0d93ed66a45..5a0b7837a3a2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_management_policy_assignments_operations import ( build_create_request, build_delete_request, @@ -36,11 +35,15 @@ build_list_for_scope_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleManagementPolicyAssignmentsOperations: +class RoleManagementPolicyAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -71,12 +74,11 @@ async def get( :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,20 +92,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,16 +112,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @overload async def create( @@ -145,7 +141,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -156,7 +151,7 @@ async def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -169,11 +164,10 @@ async def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -184,7 +178,7 @@ async def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], + parameters: Union[_models.RoleManagementPolicyAssignment, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. @@ -195,18 +189,14 @@ async def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. + RoleManagementPolicyAssignment type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,23 +219,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - request = build_create_request( + _request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,16 +242,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -276,12 +260,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -295,20 +278,18 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -318,11 +299,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicyAssignment"]: @@ -330,7 +307,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: @@ -343,7 +319,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,15 +330,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -373,14 +347,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) @@ -390,11 +363,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -405,5 +378,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py index bdd139feaa79..4552717f5dd2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py @@ -1495,7 +1495,7 @@ def __init__( self.next_link = next_link -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long """Schedule info of the role assignment schedule. :ivar start_date_time: Start DateTime of the role assignment schedule. @@ -1529,7 +1529,9 @@ def __init__( self.expiration = expiration -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long """Expiration of the role assignment schedule. :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", @@ -1570,7 +1572,7 @@ def __init__( self.duration = duration -class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long """Ticket Info of the role assignment. :ivar ticket_number: Ticket number for the role assignment. @@ -1994,7 +1996,7 @@ def __init__( self.role_eligibility_schedule_id = role_eligibility_schedule_id -class RoleEligibilityScheduleInstanceListResult(_serialization.Model): +class RoleEligibilityScheduleInstanceListResult(_serialization.Model): # pylint: disable=name-too-long """Role eligibility schedule instance list operation result. :ivar value: Role eligibility schedule instance list. @@ -2313,7 +2315,7 @@ def __init__( self.next_link = next_link -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long """Schedule info of the role eligibility schedule. :ivar start_date_time: Start DateTime of the role eligibility schedule. @@ -2347,7 +2349,9 @@ def __init__( self.expiration = expiration -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long """Expiration of the role eligibility schedule. :ivar type: Type of the role eligibility schedule expiration. Known values are: @@ -2388,7 +2392,7 @@ def __init__( self.duration = duration -class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long """Ticket Info of the role eligibility. :ivar ticket_number: Ticket number for the role eligibility. @@ -2518,7 +2522,7 @@ class RoleManagementPolicyRule(_serialization.Model): RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -2574,7 +2578,7 @@ def __init__( class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -2730,10 +2734,10 @@ def __init__( self.next_link = next_link -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): +class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): # pylint: disable=name-too-long """The role management policy authentication context rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -2791,7 +2795,7 @@ def __init__( class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy enablement rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -2844,7 +2848,7 @@ def __init__( class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -2934,7 +2938,7 @@ def __init__( class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py index 91c9a599883e..dc953c2a80d8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_get_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -93,7 +96,6 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. 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 EligibleChildResource or the result of cls(response) :rtype: @@ -106,7 +108,7 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,16 +119,14 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab def prepare_request(next_link=None): if not next_link: - request = build_get_request( + _request = build_get_request( scope=scope, filter=filter, 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) else: # make call to next link with the client's api-version @@ -137,14 +137,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) @@ -154,11 +153,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,5 +168,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py index e8ca1d811b0b..de28c518e590 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -81,7 +84,7 @@ def build_get_request(scope: str, role_assignment_schedule_instance_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +95,7 @@ def build_get_request(scope: str, role_assignment_schedule_instance_name: str, * return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleAssignmentScheduleInstancesOperations: +class RoleAssignmentScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -127,7 +130,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedule instances created for the current user. 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 RoleAssignmentScheduleInstance or the result of cls(response) :rtype: @@ -140,7 +142,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -151,16 +153,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -171,14 +171,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) @@ -188,11 +187,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,8 +203,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - @distributed_trace def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any @@ -217,12 +214,11 @@ def get( :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,20 +232,18 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,13 +252,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py index 542edabc6b52..e3fa7410e8c9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_create_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +92,7 @@ def build_get_request(scope: str, role_assignment_schedule_request_name: str, ** ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +116,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -145,7 +148,7 @@ def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -176,7 +179,7 @@ def build_validate_request(scope: str, role_assignment_schedule_request_name: st ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -236,7 +239,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +249,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -265,11 +267,10 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -280,7 +281,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -296,18 +297,14 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,23 +327,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,16 +350,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -377,12 +368,11 @@ def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,20 +386,18 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,16 +406,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -445,7 +429,6 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. 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 RoleAssignmentScheduleRequest or the result of cls(response) :rtype: @@ -458,7 +441,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,16 +452,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -489,14 +470,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -506,11 +486,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -522,8 +502,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any @@ -535,12 +513,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,20 +531,18 @@ def cancel( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,11 +552,7 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def validate( @@ -605,7 +576,6 @@ def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -616,7 +586,7 @@ def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -629,11 +599,10 @@ def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -644,7 +613,7 @@ def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Validates a new role assignment schedule request. @@ -655,18 +624,14 @@ def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -689,23 +654,21 @@ def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +677,9 @@ def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py index a6edd5760f1b..1dc2876fd367 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_get_request(scope: str, role_assignment_schedule_name: str, **kwargs: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -121,12 +124,11 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,20 +142,18 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,16 +162,12 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) + deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -188,7 +184,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. 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 RoleAssignmentSchedule or the result of cls(response) :rtype: @@ -201,7 +196,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,16 +207,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -232,14 +225,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) @@ -249,11 +241,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,5 +256,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py index 84baa462231c..373ea42f78c5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -81,7 +84,7 @@ def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +95,7 @@ def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleEligibilityScheduleInstancesOperations: +class RoleEligibilityScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -127,7 +130,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilityScheduleInstance or the result of cls(response) :rtype: @@ -140,7 +142,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -151,16 +153,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -171,14 +171,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) @@ -188,11 +187,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,8 +203,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - @distributed_trace def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any @@ -217,12 +214,11 @@ def get( :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,20 +232,18 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,13 +252,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py index 03cb9acf3abe..37046e5f24e6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_create_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +92,7 @@ def build_get_request(scope: str, role_eligibility_schedule_request_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +116,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -145,7 +148,7 @@ def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -176,7 +179,7 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -189,7 +192,7 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -236,7 +239,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +249,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -265,11 +267,10 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -280,7 +281,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -296,18 +297,14 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,23 +327,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,16 +350,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -377,12 +368,11 @@ def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,20 +386,18 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,16 +406,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -445,7 +429,6 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. 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 RoleEligibilityScheduleRequest or the result of cls(response) :rtype: @@ -458,7 +441,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,16 +452,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -489,14 +470,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -506,11 +486,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -522,8 +502,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any @@ -535,12 +513,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,20 +531,18 @@ def cancel( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,11 +552,7 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def validate( @@ -605,7 +576,6 @@ def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -616,7 +586,7 @@ def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -629,11 +599,10 @@ def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -644,7 +613,7 @@ def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Validates a new role eligibility schedule request. @@ -655,18 +624,14 @@ def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -689,23 +654,21 @@ def validate( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +677,9 @@ def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py index 9d7ba4e73c05..71c5154ea568 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_get_request(scope: str, role_eligibility_schedule_name: str, **kwargs: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -121,12 +124,11 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,20 +142,18 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,16 +162,12 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) + deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -188,7 +184,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilitySchedule or the result of cls(response) :rtype: @@ -201,7 +196,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,16 +207,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -232,14 +225,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) @@ -249,11 +241,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,5 +256,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py index 57aa735de0b9..9fb06dbf599e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_get_request(scope: str, role_management_policy_name: str, **kwargs: An "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +84,7 @@ def build_update_request(scope: str, role_management_policy_name: str, **kwargs: "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,7 +113,7 @@ def build_delete_request(scope: str, role_management_policy_name: str, **kwargs: "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +137,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,12 +177,11 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,20 +195,18 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +215,12 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @overload def update( @@ -248,7 +244,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -259,7 +254,7 @@ def update( self, scope: str, role_management_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -272,11 +267,10 @@ def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -287,7 +281,7 @@ def update( self, scope: str, role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], + parameters: Union[_models.RoleManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. @@ -298,17 +292,14 @@ def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy or + IO[bytes] :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,23 +322,21 @@ def update( else: _json = self._serialize.body(parameters, "RoleManagementPolicy") - request = build_update_request( + _request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -356,16 +345,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -378,12 +363,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -397,20 +381,18 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -420,11 +402,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicy"]: @@ -432,7 +410,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: @@ -445,7 +422,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -456,15 +433,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -475,14 +450,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) @@ -492,11 +466,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,5 +481,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py index d15880273785..a7f2319b5c56 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_get_request(scope: str, role_management_policy_assignment_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_create_request(scope: str, role_management_policy_assignment_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -119,7 +122,7 @@ def build_delete_request(scope: str, role_management_policy_assignment_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +146,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +157,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleManagementPolicyAssignmentsOperations: +class RoleManagementPolicyAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -185,12 +188,11 @@ def get( :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,20 +206,18 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,16 +226,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @overload def create( @@ -259,7 +255,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +265,7 @@ def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -283,11 +278,10 @@ def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +292,7 @@ def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], + parameters: Union[_models.RoleManagementPolicyAssignment, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. @@ -309,18 +303,14 @@ def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. + RoleManagementPolicyAssignment type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,23 +333,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - request = build_create_request( + _request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,16 +356,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -390,12 +374,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,20 +392,18 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -432,11 +413,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicyAssignment"]: @@ -444,7 +421,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: @@ -457,7 +433,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -468,15 +444,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -487,14 +461,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) @@ -504,11 +477,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -519,5 +492,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py index 1673bed51664..3fb3ed335d8d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -90,7 +93,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -127,7 +148,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -147,12 +168,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py index a86bb2b1c86e..d86f66fc395f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json index 90e687cae95a..5f9190f744f4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignments": "RoleAssignmentsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py index b489128766ea..625cad18a4fd 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -90,7 +93,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -127,7 +148,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -147,12 +170,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py index bcfc50b7f475..0c6f5e2dbb42 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py index bd707b2c4a44..5f43feda83bd 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._eligible_child_resources_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +69,6 @@ def get( $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. 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 EligibleChildResource or the result of cls(response) :rtype: @@ -81,7 +83,7 @@ def get( ) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,16 +94,14 @@ def get( def prepare_request(next_link=None): if not next_link: - request = build_get_request( + _request = build_get_request( scope=scope, filter=filter, 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) else: # make call to next link with the client's api-version @@ -112,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) @@ -129,11 +128,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,5 +143,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py index c843d2b73cbc..b7306016d8e0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,22 +20,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleAssignmentScheduleInstancesOperations: +class RoleAssignmentScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -69,7 +72,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedule instances created for the current user. 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 RoleAssignmentScheduleInstance or the result of cls(response) :rtype: @@ -84,7 +86,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,16 +97,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -115,14 +115,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) @@ -132,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -148,8 +147,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any @@ -161,12 +158,11 @@ async def get( :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -182,20 +178,18 @@ async def get( ) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,13 +198,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py index 7149df82ace8..67a063194d7e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -36,6 +35,10 @@ build_list_for_scope_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +92,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -100,7 +102,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -119,11 +121,10 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -134,7 +135,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -151,18 +152,14 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,23 +184,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,16 +207,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -234,12 +225,11 @@ async def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,20 +245,18 @@ async def get( ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -277,16 +265,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -304,7 +288,6 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. 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 RoleAssignmentScheduleRequest or the result of cls(response) :rtype: @@ -319,7 +302,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,16 +313,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -350,14 +331,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -367,11 +347,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -383,8 +363,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any @@ -396,12 +374,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -417,20 +394,18 @@ async def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -440,8 +415,4 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py index b44a610ed4b9..1a550025ffbf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._role_assignment_schedules_operations import build_get_request, build_list_for_scope_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,12 +68,11 @@ async def get( :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,20 +88,18 @@ async def get( ) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,16 +108,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) + deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -134,7 +130,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. 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 RoleAssignmentSchedule or the result of cls(response) :rtype: @@ -149,7 +144,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -160,16 +155,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -180,14 +173,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) @@ -197,11 +189,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,5 +204,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py index 2c57a419901d..8fc3500fb724 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, @@ -44,6 +43,10 @@ build_validate_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +83,6 @@ def list_for_subscription( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -94,7 +96,7 @@ def list_for_subscription( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,17 +107,15 @@ def list_for_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_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) else: # make call to next link with the client's api-version @@ -126,14 +126,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -143,11 +142,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,10 +159,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -179,7 +174,6 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -193,7 +187,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,18 +198,16 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -226,14 +218,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -243,11 +234,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,10 +251,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource( self, @@ -293,7 +280,6 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -307,7 +293,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,7 +304,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, @@ -327,12 +313,10 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -343,14 +327,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -360,11 +343,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -377,10 +360,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -398,12 +377,11 @@ async def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,21 +397,19 @@ async def get( ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -443,14 +419,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def create( @@ -479,7 +453,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -490,7 +463,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -507,11 +480,10 @@ async def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -522,7 +494,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. @@ -537,18 +509,15 @@ async def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -573,23 +542,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,19 +566,13 @@ async def create( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -629,12 +590,11 @@ async def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -650,21 +610,19 @@ async def delete( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -676,14 +634,12 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def validate( @@ -712,7 +668,6 @@ async def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -723,7 +678,7 @@ async def validate( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -740,11 +695,10 @@ async def validate( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -755,7 +709,7 @@ async def validate( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. @@ -770,18 +724,15 @@ async def validate( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -806,23 +757,21 @@ async def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -832,16 +781,12 @@ async def validate( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidationResponse", pipeline_response) + deserialized = self._deserialize("ValidationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -861,7 +806,6 @@ def list_for_scope( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -875,7 +819,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,17 +830,15 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -907,14 +849,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -924,11 +865,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -941,8 +882,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace_async async def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -957,12 +896,11 @@ async def get_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -978,20 +916,18 @@ async def get_by_id( ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1001,14 +937,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload async def create_by_id( @@ -1033,7 +967,6 @@ async def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -1041,7 +974,7 @@ async def create_by_id( @overload async def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -1052,11 +985,10 @@ async def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -1064,7 +996,10 @@ async def create_by_id( @distributed_trace_async async def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -1075,18 +1010,15 @@ async def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1111,22 +1043,20 @@ async def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1136,19 +1066,13 @@ async def create_by_id( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -1163,12 +1087,11 @@ async def delete_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1184,20 +1107,18 @@ async def delete_by_id( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1209,14 +1130,12 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload async def validate_by_id( @@ -1241,7 +1160,6 @@ async def validate_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1249,7 +1167,7 @@ async def validate_by_id( @overload async def validate_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. @@ -1260,11 +1178,10 @@ async def validate_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1272,7 +1189,10 @@ async def validate_by_id( @distributed_trace_async async def validate_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. @@ -1283,18 +1203,15 @@ async def validate_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1319,22 +1236,20 @@ async def validate_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_validate_by_id_request( + _request = build_validate_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1344,11 +1259,9 @@ async def validate_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidationResponse", pipeline_response) + deserialized = self._deserialize("ValidationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_by_id.metadata = {"url": "/{roleAssignmentId}/validate"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py index 6561dfb24dd5..a3ae1c937e0e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,25 +20,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_instances_operations import ( build_get_request, build_list_for_scope_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleEligibilityScheduleInstancesOperations: +class RoleEligibilityScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +75,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilityScheduleInstance or the result of cls(response) :rtype: @@ -87,7 +89,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,16 +100,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +118,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) @@ -135,11 +134,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,8 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any @@ -164,12 +161,11 @@ async def get( :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -185,20 +181,18 @@ async def get( ) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,13 +201,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py index ee9875766ca6..016d45122f5f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -36,11 +35,15 @@ build_list_for_scope_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -89,7 +92,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -100,7 +102,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -119,11 +121,10 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -134,7 +135,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -151,18 +152,15 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or + IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,23 +185,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,16 +208,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -234,12 +226,11 @@ async def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,20 +246,18 @@ async def get( ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -277,16 +266,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -304,7 +289,6 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. 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 RoleEligibilityScheduleRequest or the result of cls(response) :rtype: @@ -319,7 +303,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,16 +314,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -350,14 +332,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -367,11 +348,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -383,8 +364,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any @@ -396,12 +375,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -417,20 +395,18 @@ async def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -440,8 +416,4 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py index 5ff534c83217..9bf49eb4e573 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._role_eligibility_schedules_operations import build_get_request, build_list_for_scope_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,12 +68,11 @@ async def get( :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,20 +88,18 @@ async def get( ) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,16 +108,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) + deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -134,7 +130,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilitySchedule or the result of cls(response) :rtype: @@ -149,7 +144,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -160,16 +155,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -180,14 +173,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) @@ -197,11 +189,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,5 +204,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py index da805b810844..de36d7088973 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_management_policies_operations import ( build_delete_request, build_get_request, @@ -36,6 +35,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,12 +72,11 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,20 +92,18 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) ) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,16 +112,12 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @overload async def update( @@ -145,7 +141,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -156,7 +151,7 @@ async def update( self, scope: str, role_management_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -169,11 +164,10 @@ async def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -184,7 +178,7 @@ async def update( self, scope: str, role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], + parameters: Union[_models.RoleManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. @@ -195,18 +189,14 @@ async def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. + type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,23 +221,21 @@ async def update( else: _json = self._serialize.body(parameters, "RoleManagementPolicy") - request = build_update_request( + _request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -256,16 +244,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -278,12 +262,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,20 +282,18 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -322,11 +303,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicy"]: @@ -334,7 +311,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: @@ -349,7 +325,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro ) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,15 +336,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -379,14 +353,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) @@ -396,11 +369,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -411,5 +384,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py index 818a1455ed84..74b69443db0f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_management_policy_assignments_operations import ( build_create_request, build_delete_request, @@ -36,11 +35,15 @@ build_list_for_scope_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleManagementPolicyAssignmentsOperations: +class RoleManagementPolicyAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -71,12 +74,11 @@ async def get( :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,20 +94,18 @@ async def get( ) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,16 +114,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @overload async def create( @@ -148,7 +144,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -159,7 +154,7 @@ async def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -172,11 +167,10 @@ async def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -187,7 +181,7 @@ async def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], + parameters: Union[_models.RoleManagementPolicyAssignment, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. @@ -198,18 +192,15 @@ async def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. + RoleManagementPolicyAssignment type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or + IO[bytes] :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,23 +225,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - request = build_create_request( + _request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,16 +248,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -281,12 +266,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,20 +286,18 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -325,11 +307,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicyAssignment"]: @@ -337,7 +315,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: @@ -352,7 +329,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro ) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,15 +340,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -382,14 +357,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) @@ -399,11 +373,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,5 +388,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py index f75709cee514..b08cb87fabd3 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py @@ -955,7 +955,7 @@ class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=t 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. + All required parameters must be populated in order to send to server. :ivar scope: The role assignment scope. :vartype scope: str @@ -1908,7 +1908,7 @@ def __init__( self.next_link = next_link -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long """Schedule info of the role assignment schedule. :ivar start_date_time: Start DateTime of the role assignment schedule. @@ -1935,14 +1935,16 @@ def __init__( :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role assignment schedule. :paramtype expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration # pylint: disable=line-too-long """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long """Expiration of the role assignment schedule. :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", @@ -1983,7 +1985,7 @@ def __init__( self.duration = duration -class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long """Ticket Info of the role assignment. :ivar ticket_number: Ticket number for the role assignment. @@ -2415,7 +2417,7 @@ def __init__( self.role_eligibility_schedule_id = role_eligibility_schedule_id -class RoleEligibilityScheduleInstanceListResult(_serialization.Model): +class RoleEligibilityScheduleInstanceListResult(_serialization.Model): # pylint: disable=name-too-long """Role eligibility schedule instance list operation result. :ivar value: Role eligibility schedule instance list. @@ -2739,7 +2741,7 @@ def __init__( self.next_link = next_link -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long """Schedule info of the role eligibility schedule. :ivar start_date_time: Start DateTime of the role eligibility schedule. @@ -2766,14 +2768,16 @@ def __init__( :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role eligibility schedule. :paramtype expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration # pylint: disable=line-too-long """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long """Expiration of the role eligibility schedule. :ivar type: Type of the role eligibility schedule expiration. Known values are: @@ -2814,7 +2818,7 @@ def __init__( self.duration = duration -class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long """Ticket Info of the role eligibility. :ivar ticket_number: Ticket number for the role eligibility. @@ -2947,7 +2951,7 @@ class RoleManagementPolicyRule(_serialization.Model): RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -3005,7 +3009,7 @@ def __init__( class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -3157,10 +3161,10 @@ def __init__( self.next_link = next_link -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): +class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): # pylint: disable=name-too-long """The role management policy authentication context rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -3220,7 +3224,7 @@ def __init__( class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -3275,7 +3279,7 @@ def __init__( class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -3368,7 +3372,7 @@ def __init__( class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py index 0de809492db8..3b47b44997c2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_get_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -93,7 +96,6 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. 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 EligibleChildResource or the result of cls(response) :rtype: @@ -108,7 +110,7 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab ) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,16 +121,14 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab def prepare_request(next_link=None): if not next_link: - request = build_get_request( + _request = build_get_request( scope=scope, filter=filter, 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) else: # make call to next link with the client's api-version @@ -139,14 +139,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) @@ -156,11 +155,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -171,5 +170,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py index 4df4b3d9601e..5e10a2e3946a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -81,7 +84,7 @@ def build_get_request(scope: str, role_assignment_schedule_instance_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +95,7 @@ def build_get_request(scope: str, role_assignment_schedule_instance_name: str, * return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleAssignmentScheduleInstancesOperations: +class RoleAssignmentScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -127,7 +130,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedule instances created for the current user. 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 RoleAssignmentScheduleInstance or the result of cls(response) :rtype: @@ -142,7 +144,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,16 +155,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -173,14 +173,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) @@ -190,11 +189,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,8 +205,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - @distributed_trace def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any @@ -219,12 +216,11 @@ def get( :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -240,20 +236,18 @@ def get( ) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,13 +256,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py index a6c978ce2b2f..432e622a98b8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_create_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +92,7 @@ def build_get_request(scope: str, role_assignment_schedule_request_name: str, ** ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +116,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -145,7 +148,7 @@ def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -205,7 +208,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -216,7 +218,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -235,11 +237,10 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -250,7 +251,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -267,18 +268,14 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,23 +300,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -328,16 +323,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -350,12 +341,11 @@ def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,20 +361,18 @@ def get( ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +381,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -420,7 +404,6 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. 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 RoleAssignmentScheduleRequest or the result of cls(response) :rtype: @@ -435,7 +418,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -446,16 +429,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -466,14 +447,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -483,11 +463,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,8 +479,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any @@ -512,12 +490,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,20 +510,18 @@ def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -556,8 +531,4 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py index d48d9d282408..15b95dd75f81 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_get_request(scope: str, role_assignment_schedule_name: str, **kwargs: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -121,12 +124,11 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -142,20 +144,18 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> ) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,16 +164,12 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) + deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -190,7 +186,6 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. 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 RoleAssignmentSchedule or the result of cls(response) :rtype: @@ -205,7 +200,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,16 +211,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -236,14 +229,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) @@ -253,11 +245,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -268,5 +260,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py index 98836d3722c6..1e2c0b2416ee 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_list_for_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +98,7 @@ def build_list_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,7 +147,7 @@ def build_list_for_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -175,7 +178,7 @@ def build_get_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +206,7 @@ def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -232,7 +235,7 @@ def build_delete_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +265,7 @@ def build_validate_request(scope: str, role_assignment_name: str, **kwargs: Any) "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -290,7 +293,7 @@ def build_list_for_scope_request( "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -318,7 +321,7 @@ def build_get_by_id_request(role_assignment_id: str, *, tenant_id: Optional[str] "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -345,7 +348,7 @@ def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRe "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -373,7 +376,7 @@ def build_delete_by_id_request( "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -400,7 +403,7 @@ def build_validate_by_id_request(role_assignment_id: str, **kwargs: Any) -> Http "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -445,7 +448,6 @@ def list_for_subscription( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -459,7 +461,7 @@ def list_for_subscription( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,17 +472,15 @@ def list_for_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_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) else: # make call to next link with the client's api-version @@ -491,14 +491,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -508,11 +507,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,10 +524,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -544,7 +539,6 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -558,7 +552,7 @@ def list_for_resource_group( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,18 +563,16 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -591,14 +583,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -608,11 +599,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -625,10 +616,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource( self, @@ -658,7 +645,6 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -672,7 +658,7 @@ def list_for_resource( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -683,7 +669,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, @@ -692,12 +678,10 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -708,14 +692,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -725,11 +708,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -742,10 +725,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -763,12 +742,11 @@ def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -784,21 +762,19 @@ def get( ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -808,14 +784,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def create( @@ -844,7 +818,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -855,7 +828,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -872,11 +845,10 @@ def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -887,7 +859,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. @@ -902,18 +874,15 @@ def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -938,23 +907,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -964,19 +931,13 @@ def create( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -994,12 +955,11 @@ def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1015,21 +975,19 @@ def delete( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1041,14 +999,12 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def validate( @@ -1077,7 +1033,6 @@ def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1088,7 +1043,7 @@ def validate( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1105,11 +1060,10 @@ def validate( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1120,7 +1074,7 @@ def validate( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. @@ -1135,18 +1089,15 @@ def validate( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1171,23 +1122,21 @@ def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1197,16 +1146,12 @@ def validate( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidationResponse", pipeline_response) + deserialized = self._deserialize("ValidationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -1226,7 +1171,6 @@ def list_for_scope( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] @@ -1240,7 +1184,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1251,17 +1195,15 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1272,14 +1214,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1289,11 +1230,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1306,8 +1247,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -1322,12 +1261,11 @@ def get_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1343,20 +1281,18 @@ def get_by_id( ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1366,14 +1302,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload def create_by_id( @@ -1398,7 +1332,6 @@ def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -1406,7 +1339,7 @@ def create_by_id( @overload def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -1417,11 +1350,10 @@ def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -1429,7 +1361,10 @@ def create_by_id( @distributed_trace def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -1440,18 +1375,15 @@ def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1476,22 +1408,20 @@ def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1501,19 +1431,13 @@ def create_by_id( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - @distributed_trace def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -1528,12 +1452,11 @@ def delete_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1549,20 +1472,18 @@ def delete_by_id( ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1574,14 +1495,12 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload def validate_by_id( @@ -1606,7 +1525,6 @@ def validate_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1614,7 +1532,7 @@ def validate_by_id( @overload def validate_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. @@ -1625,11 +1543,10 @@ def validate_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1637,7 +1554,10 @@ def validate_by_id( @distributed_trace def validate_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. @@ -1648,18 +1568,15 @@ def validate_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or + IO[bytes] :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1684,22 +1601,20 @@ def validate_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_validate_by_id_request( + _request = build_validate_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1709,11 +1624,9 @@ def validate_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidationResponse", pipeline_response) + deserialized = self._deserialize("ValidationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_by_id.metadata = {"url": "/{roleAssignmentId}/validate"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py index 462d376f9d30..8c68c1c94b09 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -81,7 +84,7 @@ def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +95,7 @@ def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleEligibilityScheduleInstancesOperations: +class RoleEligibilityScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -127,7 +130,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilityScheduleInstance or the result of cls(response) :rtype: @@ -142,7 +144,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,16 +155,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -173,14 +173,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) @@ -190,11 +189,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,8 +205,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - @distributed_trace def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any @@ -219,12 +216,11 @@ def get( :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -240,20 +236,18 @@ def get( ) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,13 +256,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py index 179ab436ba63..3e1f3cae6d24 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_create_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +92,7 @@ def build_get_request(scope: str, role_eligibility_schedule_request_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +116,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -145,7 +148,7 @@ def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -156,7 +159,7 @@ def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -205,7 +208,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -216,7 +218,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -235,11 +237,10 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -250,7 +251,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -267,18 +268,15 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or + IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,23 +301,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -328,16 +324,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -350,12 +342,11 @@ def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,20 +362,18 @@ def get( ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +382,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -420,7 +405,6 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. 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 RoleEligibilityScheduleRequest or the result of cls(response) :rtype: @@ -435,7 +419,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -446,16 +430,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -466,14 +448,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -483,11 +464,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,8 +480,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any @@ -512,12 +491,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,20 +511,18 @@ def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -556,8 +532,4 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py index f7b2e7ba2fa6..6df2c7eb6a80 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_get_request(scope: str, role_eligibility_schedule_name: str, **kwargs: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -121,12 +124,11 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -142,20 +144,18 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> ) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,16 +164,12 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) + deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -190,7 +186,6 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. 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 RoleEligibilitySchedule or the result of cls(response) :rtype: @@ -205,7 +200,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,16 +211,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -236,14 +229,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) @@ -253,11 +245,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -268,5 +260,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py index 95f8a85ac085..997cc94793d5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_get_request(scope: str, role_management_policy_name: str, **kwargs: An "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +84,7 @@ def build_update_request(scope: str, role_management_policy_name: str, **kwargs: "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,7 +113,7 @@ def build_delete_request(scope: str, role_management_policy_name: str, **kwargs: "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +137,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,12 +177,11 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,20 +197,18 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m ) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -217,16 +217,12 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @overload def update( @@ -250,7 +246,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -261,7 +256,7 @@ def update( self, scope: str, role_management_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -274,11 +269,10 @@ def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -289,7 +283,7 @@ def update( self, scope: str, role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], + parameters: Union[_models.RoleManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. @@ -300,18 +294,14 @@ def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. + type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,23 +326,21 @@ def update( else: _json = self._serialize.body(parameters, "RoleManagementPolicy") - request = build_update_request( + _request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,16 +349,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -383,12 +367,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,20 +387,18 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -427,11 +408,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicy"]: @@ -439,7 +416,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: @@ -454,7 +430,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan ) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,15 +441,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -484,14 +458,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) @@ -501,11 +474,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,5 +489,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py index 2a9a210e7a20..2f5e5bac5714 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_get_request(scope: str, role_management_policy_assignment_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_create_request(scope: str, role_management_policy_assignment_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -119,7 +122,7 @@ def build_delete_request(scope: str, role_management_policy_assignment_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +146,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +157,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleManagementPolicyAssignmentsOperations: +class RoleManagementPolicyAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -185,12 +188,11 @@ def get( :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,20 +208,18 @@ def get( ) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -228,16 +228,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @overload def create( @@ -262,7 +258,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +268,7 @@ def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,11 +281,10 @@ def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -301,7 +295,7 @@ def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], + parameters: Union[_models.RoleManagementPolicyAssignment, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. @@ -312,18 +306,15 @@ def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. + RoleManagementPolicyAssignment type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or + IO[bytes] :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -348,23 +339,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - request = build_create_request( + _request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,16 +362,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -395,12 +380,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -416,20 +400,18 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -439,11 +421,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicyAssignment"]: @@ -451,7 +429,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: @@ -466,7 +443,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan ) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,15 +454,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -496,14 +471,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) @@ -513,11 +487,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,5 +502,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py index 6fe9e6b5e358..af29fc05def7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -68,7 +71,25 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -96,7 +117,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -116,12 +137,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py index 6dd3f3d72079..47bee7d06020 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json index c964b3aa4069..468359116e82 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -88,8 +88,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py index 26d5b0b18a30..91772de2aff1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -68,7 +71,25 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -96,7 +117,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -116,12 +139,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py index d9c6a3b71eb0..128bc4411c58 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py index 21203e527e40..8acf4b7d3a88 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_01_01_preview.models.Operation] @@ -71,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +84,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -100,14 +100,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _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) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py index ef6aede4d8f1..94a54a9a7fa4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._role_assignment_approval_operations import build_get_by_id_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +70,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m returned list only includes all role assignment approvals that the calling user has requests targeted for. 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 RoleAssignmentApproval or the result of cls(response) :rtype: @@ -82,7 +84,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,15 +95,13 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -112,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) @@ -129,11 +128,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,20 +145,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} - @distributed_trace_async async def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,19 +171,17 @@ async def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssign ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,11 +191,9 @@ async def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssign error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py index 911e15f5a852..7cd4cb1b9f68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +19,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_approval_step_operations import ( build_get_by_id_request, build_patch_request, build_put_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,12 +67,11 @@ async def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _mo :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,20 +87,18 @@ async def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _mo ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,16 +108,12 @@ async def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore @overload async def patch( @@ -141,7 +137,6 @@ async def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -149,7 +144,13 @@ async def patch( @overload async def patch( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + approval_id: str, + stage_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -158,11 +159,10 @@ async def patch( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -173,7 +173,7 @@ async def patch( self, approval_id: str, stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -183,18 +183,15 @@ async def patch( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,23 +216,21 @@ async def patch( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_patch_request( + _request = build_patch_request( approval_id=approval_id, stage_id=stage_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -245,14 +240,12 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} + return deserialized # type: ignore @overload async def put( @@ -276,7 +269,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -284,7 +276,13 @@ async def put( @overload async def put( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + approval_id: str, + stage_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -293,11 +291,10 @@ async def put( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +305,7 @@ async def put( self, approval_id: str, stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -318,18 +315,15 @@ async def put( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,23 +348,21 @@ async def put( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_put_request( + _request = build_put_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,11 +372,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py index 9ddcbca25087..6b5b0afcbac1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_approval_steps_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,13 +60,12 @@ async def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentA :param approval_id: The id of the role assignment approval. Required. :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,19 +81,17 @@ async def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentA ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( approval_id=approval_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -101,11 +101,9 @@ async def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentA error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py index 06e5aeb7e332..11ab001166ff 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._scope_role_assignment_approval_operations import build_get_by_id_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,6 @@ def list( returned list only includes all role assignment approvals that the calling user has requests targeted for. 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 RoleAssignmentApproval or the result of cls(response) :rtype: @@ -86,7 +88,7 @@ def list( ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,16 +99,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +117,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) @@ -134,11 +133,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,8 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} - @distributed_trace_async async def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. @@ -161,12 +158,11 @@ async def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _model :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -182,20 +178,18 @@ async def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _model ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_id, scope=scope, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,11 +199,9 @@ async def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _model error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py index c45868f6f320..d1210d3725cb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,25 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_role_assignment_approval_step_operations import ( build_get_by_id_request, build_patch_request, build_put_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeRoleAssignmentApprovalStepOperations: +class ScopeRoleAssignmentApprovalStepOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -68,12 +71,11 @@ async def get_by_id( :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,21 +91,19 @@ async def get_by_id( ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, scope=scope, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,16 +113,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore @overload async def patch( @@ -149,7 +145,6 @@ async def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -161,7 +156,7 @@ async def patch( approval_id: str, stage_id: str, scope: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -175,11 +170,10 @@ async def patch( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -191,7 +185,7 @@ async def patch( approval_id: str, stage_id: str, scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -203,18 +197,15 @@ async def patch( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,7 +230,7 @@ async def patch( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_patch_request( + _request = build_patch_request( approval_id=approval_id, stage_id=stage_id, scope=scope, @@ -247,16 +238,14 @@ async def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -266,16 +255,12 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore @overload async def put( @@ -302,7 +287,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -314,7 +298,7 @@ async def put( approval_id: str, stage_id: str, scope: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -328,11 +312,10 @@ async def put( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -344,7 +327,7 @@ async def put( approval_id: str, stage_id: str, scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -356,18 +339,15 @@ async def put( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,7 +372,7 @@ async def put( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_put_request( + _request = build_put_request( approval_id=approval_id, stage_id=stage_id, scope=scope, @@ -400,16 +380,14 @@ async def put( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,13 +397,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py index bcf5c7229157..30012ac76300 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,21 +18,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._scope_role_assignment_approval_steps_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeRoleAssignmentApprovalStepsOperations: +class ScopeRoleAssignmentApprovalStepsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -59,13 +62,12 @@ async def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.Rol :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,20 +83,18 @@ async def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.Rol ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( approval_id=approval_id, scope=scope, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -104,11 +104,9 @@ async def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py index 548e4758bdcc..588862837f7c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +82,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_01_01_preview.models.Operation] @@ -93,7 +95,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,14 +106,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -122,14 +122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -139,11 +138,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py index 44572006418a..5c3d0971c334 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +73,7 @@ def build_get_by_id_request(approval_id: str, **kwargs: Any) -> HttpRequest: "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +117,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models returned list only includes all role assignment approvals that the calling user has requests targeted for. 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 RoleAssignmentApproval or the result of cls(response) :rtype: @@ -129,7 +131,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,15 +142,13 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -159,14 +159,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) @@ -176,11 +175,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -193,20 +192,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} - @distributed_trace def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -222,19 +218,17 @@ def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentAp ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,11 +238,9 @@ def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentAp error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py index 4e87856a8042..51f0986e97de 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_by_id_request(approval_id: str, stage_id: str, **kwargs: Any) -> H "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_patch_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpR "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,7 +112,7 @@ def build_put_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpReq "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -150,12 +153,11 @@ def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.R :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -171,20 +173,18 @@ def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.R ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,16 +194,12 @@ def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.R error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore @overload def patch( @@ -227,7 +223,6 @@ def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -235,7 +230,13 @@ def patch( @overload def patch( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + approval_id: str, + stage_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -244,11 +245,10 @@ def patch( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -259,7 +259,7 @@ def patch( self, approval_id: str, stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -269,18 +269,15 @@ def patch( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,23 +302,21 @@ def patch( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_patch_request( + _request = build_patch_request( approval_id=approval_id, stage_id=stage_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -331,14 +326,12 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} + return deserialized # type: ignore @overload def put( @@ -362,7 +355,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -370,7 +362,13 @@ def put( @overload def put( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + approval_id: str, + stage_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -379,11 +377,10 @@ def put( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -394,7 +391,7 @@ def put( self, approval_id: str, stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -404,18 +401,15 @@ def put( :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,23 +434,21 @@ def put( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_put_request( + _request = build_put_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -466,11 +458,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py index 212d0864a22d..91957b5a1b66 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +50,7 @@ def build_list_request(approval_id: str, **kwargs: Any) -> HttpRequest: "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,13 +87,12 @@ def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprova :param approval_id: The id of the role assignment approval. Required. :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,19 +108,17 @@ def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprova ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( approval_id=approval_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,11 +128,9 @@ def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprova error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py index 9fba479aa086..a2d6021426dd 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +79,7 @@ def build_get_by_id_request(approval_id: str, scope: str, **kwargs: Any) -> Http "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,7 +127,6 @@ def list( returned list only includes all role assignment approvals that the calling user has requests targeted for. 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 RoleAssignmentApproval or the result of cls(response) :rtype: @@ -139,7 +141,7 @@ def list( ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -150,16 +152,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -170,14 +170,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) @@ -187,11 +186,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,8 +203,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} - @distributed_trace def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. @@ -214,12 +211,11 @@ def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.Role :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -235,20 +231,18 @@ def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.Role ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_id, scope=scope, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,11 +252,9 @@ def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.Role error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py index 6b602185504e..8d104838fd73 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_get_by_id_request(approval_id: str, stage_id: str, scope: str, **kwarg "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_patch_request(approval_id: str, stage_id: str, scope: str, **kwargs: A "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -115,7 +118,7 @@ def build_put_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +131,7 @@ def build_put_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeRoleAssignmentApprovalStepOperations: +class ScopeRoleAssignmentApprovalStepOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -160,12 +163,11 @@ def get_by_id( :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,21 +183,19 @@ def get_by_id( ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, scope=scope, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,16 +205,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore @overload def patch( @@ -241,7 +237,6 @@ def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -253,7 +248,7 @@ def patch( approval_id: str, stage_id: str, scope: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -267,11 +262,10 @@ def patch( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +277,7 @@ def patch( approval_id: str, stage_id: str, scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -295,18 +289,15 @@ def patch( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,7 +322,7 @@ def patch( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_patch_request( + _request = build_patch_request( approval_id=approval_id, stage_id=stage_id, scope=scope, @@ -339,16 +330,14 @@ def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,16 +347,12 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore @overload def put( @@ -394,7 +379,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -406,7 +390,7 @@ def put( approval_id: str, stage_id: str, scope: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -420,11 +404,10 @@ def put( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: @@ -436,7 +419,7 @@ def put( approval_id: str, stage_id: str, scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], + properties: Union[_models.RoleAssignmentApprovalStepProperties, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. @@ -448,18 +431,15 @@ def put( :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. + RoleAssignmentApprovalStepProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or + IO[bytes] :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,7 +464,7 @@ def put( else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - request = build_put_request( + _request = build_put_request( approval_id=approval_id, stage_id=stage_id, scope=scope, @@ -492,16 +472,14 @@ def put( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -511,13 +489,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py index 9300cb8ffd34..1707074f086e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request(approval_id: str, scope: str, **kwargs: Any) -> HttpReque "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -61,7 +64,7 @@ def build_list_request(approval_id: str, scope: str, **kwargs: Any) -> HttpReque return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeRoleAssignmentApprovalStepsOperations: +class ScopeRoleAssignmentApprovalStepsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -89,13 +92,12 @@ def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssig :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,20 +113,18 @@ def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssig ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( approval_id=approval_id, scope=scope, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,11 +134,9 @@ def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssig error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py index 3da89379d0a1..37d5c6a9f97d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -85,7 +88,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -121,7 +142,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -141,12 +162,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py index 6c0ba0427f19..0e87137c835f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-03-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json index 9b441250f678..70f0f41bb470 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/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 = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py index ca6a9fc4c3b0..9e1b3e9d1af7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -85,7 +88,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -121,7 +142,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -141,12 +164,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py index fbaad4d60844..8ed12efe463f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-03-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py index aa90875c9933..75feccf1c04e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._access_review_default_settings_operations import build_get_request, build_put_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,12 +59,11 @@ def __init__(self, *args, **kwargs) -> None: async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -77,19 +79,17 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -99,16 +99,12 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload async def put( @@ -122,7 +118,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -130,16 +125,15 @@ async def put( @overload async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -147,23 +141,19 @@ async def put( @distributed_trace_async async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +178,20 @@ async def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,13 +201,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py index 2ea6cc3f2d42..b856ecba9737 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_decisions_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +71,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -83,7 +85,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,18 +96,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -133,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,7 +148,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py index dcc1e43bb936..c6e05661396a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,26 +21,28 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -74,7 +77,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -89,7 +91,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +102,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +121,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -138,11 +137,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -171,12 +166,11 @@ async def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,21 +186,19 @@ async def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,16 +208,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload async def patch( @@ -252,7 +240,6 @@ async def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +251,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,11 +265,10 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +280,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -306,18 +292,15 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -342,7 +325,7 @@ async def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -350,16 +333,14 @@ async def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +350,9 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py index c6ba63176273..776f59b202b6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, @@ -33,6 +32,10 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,12 +70,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +90,19 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,11 +113,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -129,12 +125,11 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -150,21 +145,19 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,11 +168,7 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -191,12 +180,11 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,21 +200,19 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -237,11 +223,7 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements @@ -253,12 +235,11 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,21 +255,19 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,11 +278,7 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -315,12 +290,11 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,20 +310,18 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +332,4 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py index 324318fbaa75..be6b6ac68902 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,25 +20,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instances_assigned_for_my_approval_operations import ( build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,7 +73,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -85,7 +87,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,16 +98,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -133,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -162,12 +157,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,20 +177,18 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,13 +198,9 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py index 4092d7620e33..eb6546cca07f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._access_review_instances_operations import build_get_by_id_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +70,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -82,7 +84,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,17 +95,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -114,14 +114,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -131,11 +130,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -148,10 +147,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -160,12 +155,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,21 +175,19 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,13 +197,9 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 8b866369d874..34b27ef85a39 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -64,7 +67,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -79,7 +81,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +92,13 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +109,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -126,11 +125,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,5 +141,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py index 0f992fe32c8f..c90fbd21172c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, @@ -37,11 +36,15 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +75,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -87,7 +89,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,16 +100,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +118,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -135,11 +134,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,22 +151,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,20 +177,18 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,16 +198,12 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -225,12 +213,11 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,20 +233,18 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,11 +255,7 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update_by_id( @@ -295,7 +276,6 @@ async def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -303,18 +283,22 @@ async def create_or_update_by_id( @overload async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -324,7 +308,7 @@ async def create_or_update_by_id( async def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -332,19 +316,15 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,23 +349,21 @@ async def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -395,16 +373,12 @@ async def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -414,12 +388,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -435,20 +408,18 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,8 +430,4 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py index 8b130fe18976..53cc3f9358b6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_03_01_preview.models.Operation] @@ -71,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +84,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -100,14 +100,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _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) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py index 866793ed7b3b..8b5c67d98ae1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py @@ -205,7 +205,7 @@ class AccessReviewDecisionIdentity(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -426,7 +426,7 @@ class AccessReviewDecisionResource(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of resource. Required. "azureRole" :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType @@ -456,12 +456,12 @@ def __init__(self, **kwargs: Any) -> None: self.display_name = None -class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): +class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): # pylint: disable=name-too-long """Service Principal Decision Target. 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -500,7 +500,7 @@ class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py index d7e6f83d0087..baea6a6113c5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,12 +119,11 @@ def __init__(self, *args, **kwargs): def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,19 +139,17 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,16 +159,12 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload def put( @@ -182,7 +178,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -190,16 +185,15 @@ def put( @overload def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -207,23 +201,19 @@ def put( @distributed_trace def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,22 +238,20 @@ def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +261,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py index d60b6ad2d3e6..912ca66c5dce 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +107,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -119,7 +121,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,18 +132,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -152,14 +152,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -169,11 +168,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -185,7 +184,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py index 329036fc2560..6ac95912fd96 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: s "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +120,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +133,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -165,7 +168,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -180,7 +182,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,17 +193,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -212,14 +212,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -229,11 +228,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -262,12 +257,11 @@ def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,21 +277,19 @@ def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,16 +299,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload def patch( @@ -343,7 +331,6 @@ def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -355,7 +342,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,11 +356,10 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -385,7 +371,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -397,18 +383,15 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -433,7 +416,7 @@ def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -441,16 +424,14 @@ def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,13 +441,9 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py index 50abda50ab06..90ca0b5dcc68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_stop_request(schedule_definition_id: str, id: str, subscription_id: st "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_reset_decisions_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +117,7 @@ def build_apply_decisions_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +148,7 @@ def build_send_reminders_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +176,7 @@ def build_accept_recommendations_request(schedule_definition_id: str, id: str, * "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,12 +217,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -235,21 +237,19 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,11 +260,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -276,12 +272,11 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,21 +292,19 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -322,11 +315,7 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -338,12 +327,11 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,21 +347,19 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,11 +370,7 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements @@ -400,12 +382,11 @@ def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,21 +402,19 @@ def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,11 +425,7 @@ def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -462,12 +437,11 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,20 +457,18 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,8 +479,4 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py index 41ed9c6bc825..88a698d080ba 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = N "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +85,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +96,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -126,7 +129,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -141,7 +143,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -152,16 +154,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -172,14 +172,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -189,11 +188,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,10 +205,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -218,12 +213,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,20 +233,18 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,13 +254,9 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py index 80a4753c2734..eb15fee4f985 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +89,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_i "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +133,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -145,7 +147,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,17 +158,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -177,14 +177,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -194,11 +193,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,10 +210,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -223,12 +218,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,21 +238,19 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -268,13 +260,9 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 00ed6fdbac0a..a9e7fe25d2ab 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRe return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -86,7 +89,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -101,7 +103,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,15 +114,13 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -131,14 +131,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -148,11 +147,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,5 +163,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py index 101bd78385fb..071c126eae11 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, * "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +114,7 @@ def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +145,7 @@ def build_create_or_update_by_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +175,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,7 +186,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -212,7 +215,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -227,7 +229,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,16 +240,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -258,14 +258,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -275,11 +274,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,22 +291,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,20 +317,18 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -346,16 +338,12 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -365,12 +353,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,20 +373,18 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,11 +395,7 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update_by_id( @@ -435,7 +416,6 @@ def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -443,18 +423,22 @@ def create_or_update_by_id( @overload def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -464,7 +448,7 @@ def create_or_update_by_id( def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -472,19 +456,15 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -509,23 +489,21 @@ def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,16 +513,12 @@ def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -554,12 +528,11 @@ def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,20 +548,18 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,8 +570,4 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py index e59c4f92435e..702b26aadf77 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +82,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_03_01_preview.models.Operation] @@ -93,7 +95,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,14 +106,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -122,14 +122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -139,11 +138,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py index f4f80a6b47c8..5156dd7651d8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -95,7 +98,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -139,7 +160,7 @@ def __init__( ) ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -159,12 +180,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py index 95c3a123e29e..6f946c64a2e1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-07-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json index c1ad5b13cc4e..d97f7530313a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py index 58ec9e4d0fea..ecc7f9d43b90 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -95,7 +98,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -139,7 +160,9 @@ def __init__( ) ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -159,12 +182,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py index 0972d8eedae4..069d219aa7cc 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-07-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py index b45ea7aa5b68..2b0c27779c93 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._access_review_default_settings_operations import build_get_request, build_put_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,12 +59,11 @@ def __init__(self, *args, **kwargs) -> None: async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -77,19 +79,17 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -99,16 +99,12 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload async def put( @@ -122,7 +118,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -130,16 +125,15 @@ async def put( @overload async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -147,23 +141,19 @@ async def put( @distributed_trace_async async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +178,20 @@ async def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,13 +201,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py index 47489dcd5700..68cf83732e44 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceContactedReviewersOperations: +class AccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -63,7 +66,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -78,7 +80,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,17 +91,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,14 +110,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -127,11 +126,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,7 +142,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py index 0a0b1e152442..6609fd310144 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_decisions_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +71,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -83,7 +85,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,18 +96,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -133,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,7 +148,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py index 0690b78e1e5a..c9ca919ef6a1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,26 +21,28 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -74,7 +77,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -89,7 +91,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +102,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +121,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -138,11 +137,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -171,12 +166,11 @@ async def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,21 +186,19 @@ async def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,16 +208,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload async def patch( @@ -252,7 +240,6 @@ async def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +251,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,11 +265,10 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +280,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -306,18 +292,15 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -342,7 +325,7 @@ async def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -350,16 +333,14 @@ async def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +350,9 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py index ef3aba0b7ede..94a83fcf000b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, @@ -33,6 +32,10 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,12 +70,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +90,19 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,11 +113,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -129,12 +125,11 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -150,21 +145,19 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,11 +168,7 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -191,12 +180,11 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,21 +200,19 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -237,11 +223,7 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements @@ -253,12 +235,11 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,21 +255,19 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,11 +278,7 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -315,12 +290,11 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,20 +310,18 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +332,4 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py index 84b325b2e4ec..61c627831226 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,25 +20,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instances_assigned_for_my_approval_operations import ( build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,7 +73,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -85,7 +87,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,16 +98,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -133,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -162,12 +157,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,20 +177,18 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,13 +198,9 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py index 255209641f6c..9cb7e11f8d08 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,21 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +75,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -87,7 +89,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +119,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -136,11 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -165,12 +160,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,21 +180,19 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +202,12 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload async def create( @@ -243,7 +231,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -254,7 +241,7 @@ async def create( self, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -266,11 +253,10 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -281,7 +267,7 @@ async def create( self, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -291,18 +277,15 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. + AccessReviewInstanceProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or + IO[bytes] :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -327,7 +310,7 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, @@ -335,16 +318,14 @@ async def create( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -354,13 +335,9 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 1d4319be31b7..9d1781549f4a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -64,7 +67,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -79,7 +81,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +92,13 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +109,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -126,11 +125,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,5 +141,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py index 3c1436545a90..aa4fed917137 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, @@ -37,11 +36,15 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +75,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -87,7 +89,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,16 +100,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +118,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -135,11 +134,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,22 +151,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,20 +177,18 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,16 +198,12 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -225,12 +213,11 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,20 +233,18 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,11 +255,7 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update_by_id( @@ -295,7 +276,6 @@ async def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -303,18 +283,22 @@ async def create_or_update_by_id( @overload async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -324,7 +308,7 @@ async def create_or_update_by_id( async def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -332,19 +316,15 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,23 +349,21 @@ async def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -395,16 +373,12 @@ async def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -414,12 +388,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -435,20 +408,18 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,8 +430,4 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py index e8116873c26a..61f860a76b0f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_07_01_preview.models.Operation] @@ -71,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +84,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -100,14 +100,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _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) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py index a4616c3cfbc9..eff0755b1513 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantLevelAccessReviewInstanceContactedReviewersOperations: +class TenantLevelAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -63,7 +66,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -78,7 +80,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,16 +91,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +109,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -126,11 +125,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,7 +141,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py index 3d2415396bf5..a48fba53f757 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py @@ -287,7 +287,7 @@ class AccessReviewDecisionIdentity(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -508,7 +508,7 @@ class AccessReviewDecisionResource(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of resource. Required. "azureRole" :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType @@ -538,12 +538,12 @@ def __init__(self, **kwargs: Any) -> None: self.display_name = None -class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): +class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): # pylint: disable=name-too-long """Service Principal Decision Target. 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -582,7 +582,7 @@ class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py index f8b6d3a3d816..36fd1361951e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,12 +119,11 @@ def __init__(self, *args, **kwargs): def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,19 +139,17 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,16 +159,12 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload def put( @@ -182,7 +178,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -190,16 +185,15 @@ def put( @overload def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -207,23 +201,19 @@ def put( @distributed_trace def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,22 +238,20 @@ def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +261,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py index 19b8ad38430f..f5d5023b2158 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_list_request(schedule_definition_id: str, id: str, subscription_id: st "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,7 +68,7 @@ def build_list_request(schedule_definition_id: str, id: str, subscription_id: st return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceContactedReviewersOperations: +class AccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -95,7 +98,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -110,7 +112,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,17 +123,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -142,14 +142,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -159,11 +158,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,7 +174,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py index f6c1fc47e437..00b9cb496b60 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +107,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -119,7 +121,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,18 +132,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -152,14 +152,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -169,11 +168,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -185,7 +184,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py index f1f5b55e4b6f..3a6178d230de 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: s "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +120,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +133,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -165,7 +168,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -180,7 +182,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,17 +193,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -212,14 +212,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -229,11 +228,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -262,12 +257,11 @@ def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,21 +277,19 @@ def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,16 +299,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload def patch( @@ -343,7 +331,6 @@ def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -355,7 +342,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,11 +356,10 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -385,7 +371,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -397,18 +383,15 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -433,7 +416,7 @@ def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -441,16 +424,14 @@ def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,13 +441,9 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py index ca56aff5c029..768dffd5e4cd 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_stop_request(schedule_definition_id: str, id: str, subscription_id: st "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_reset_decisions_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +117,7 @@ def build_apply_decisions_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +148,7 @@ def build_send_reminders_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +176,7 @@ def build_accept_recommendations_request(schedule_definition_id: str, id: str, * "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,12 +217,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -235,21 +237,19 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,11 +260,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -276,12 +272,11 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,21 +292,19 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -322,11 +315,7 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -338,12 +327,11 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,21 +347,19 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,11 +370,7 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements @@ -400,12 +382,11 @@ def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,21 +402,19 @@ def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,11 +425,7 @@ def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -462,12 +437,11 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,20 +457,18 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,8 +479,4 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py index b33a2aa2103a..85bd4cbc5bc8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = N "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +85,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +96,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -126,7 +129,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -141,7 +143,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -152,16 +154,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -172,14 +172,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -189,11 +188,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,10 +205,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -218,12 +213,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,20 +233,18 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,13 +254,9 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py index d92292975e9f..961d9858897d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_i "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +120,7 @@ def build_create_request(schedule_definition_id: str, id: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,7 +166,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -178,7 +180,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,17 +191,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -210,14 +210,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -227,11 +226,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,10 +243,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -256,12 +251,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,21 +271,19 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -301,16 +293,12 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload def create( @@ -334,7 +322,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -345,7 +332,7 @@ def create( self, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -357,11 +344,10 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -372,7 +358,7 @@ def create( self, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -382,18 +368,15 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. + AccessReviewInstanceProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or + IO[bytes] :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,7 +401,7 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, @@ -426,16 +409,14 @@ def create( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -445,13 +426,9 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 30a816283b29..4eeb3a579cab 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRe return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -86,7 +89,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -101,7 +103,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,15 +114,13 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -131,14 +131,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -148,11 +147,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,5 +163,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py index da73e4b91a1a..6614d4e72c3f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, * "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +114,7 @@ def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +145,7 @@ def build_create_or_update_by_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +175,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,7 +186,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -212,7 +215,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -227,7 +229,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,16 +240,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -258,14 +258,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -275,11 +274,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,22 +291,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,20 +317,18 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -346,16 +338,12 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -365,12 +353,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,20 +373,18 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,11 +395,7 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update_by_id( @@ -435,7 +416,6 @@ def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -443,18 +423,22 @@ def create_or_update_by_id( @overload def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -464,7 +448,7 @@ def create_or_update_by_id( def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -472,19 +456,15 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -509,23 +489,21 @@ def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,16 +513,12 @@ def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -554,12 +528,11 @@ def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,20 +548,18 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,8 +570,4 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py index 255bf222b33f..7de853fbf967 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +82,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_07_01_preview.models.Operation] @@ -93,7 +95,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,14 +106,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -122,14 +122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -139,11 +138,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py index 38730f35e65f..16381a996162 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> H "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,7 +67,7 @@ def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> H return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class TenantLevelAccessReviewInstanceContactedReviewersOperations: +class TenantLevelAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -94,7 +97,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -109,7 +111,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,16 +122,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -140,14 +140,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -157,11 +156,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +172,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py index 13a9f000d386..306fb9c72390 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -161,7 +164,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -247,7 +268,7 @@ def __init__( ) ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -267,12 +288,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py index 3e20a7c4c988..418ef3cae893 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json index 2e1c41594826..ba0d7751a8f8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py index aa83068b7f1d..30c0242a60fa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -161,7 +164,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -247,7 +268,9 @@ def __init__( ) ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -267,12 +290,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py index 7c6c3db83976..1daf5bc82604 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py index 52327653b7f3..8eb1635049f1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._access_review_default_settings_operations import build_get_request, build_put_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,12 +59,11 @@ def __init__(self, *args, **kwargs) -> None: async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -77,19 +79,17 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -99,16 +99,12 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload async def put( @@ -122,7 +118,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -130,16 +125,15 @@ async def put( @overload async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -147,23 +141,19 @@ async def put( @distributed_trace_async async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +178,20 @@ async def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,13 +201,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py index 19054fa67e9f..d02ae16243db 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,21 +18,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._access_review_history_definition_instance_operations import build_generate_download_uri_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewHistoryDefinitionInstanceOperations: +class AccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -63,12 +66,11 @@ async def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,21 +86,19 @@ async def generate_download_uri( ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +108,9 @@ async def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_download_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py index 2d55e63dfc3c..0df88f8a3ade 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_history_definition_instances_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewHistoryDefinitionInstancesOperations: +class AccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -59,7 +62,6 @@ def list(self, history_definition_id: str, **kwargs: Any) -> AsyncIterable["_mod :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: @@ -74,7 +76,7 @@ def list(self, history_definition_id: str, **kwargs: Any) -> AsyncIterable["_mod ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,16 +87,14 @@ def list(self, history_definition_id: str, **kwargs: Any) -> AsyncIterable["_mod def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -105,14 +105,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -122,11 +121,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py index d666347c29aa..74fef6dd3939 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._access_review_history_definition_operations import build_create_request, build_delete_by_id_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -79,18 +81,22 @@ async def create( @overload async def create( - self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + history_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -100,7 +106,7 @@ async def create( async def create( self, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -108,19 +114,15 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -145,23 +147,21 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -171,16 +171,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -190,12 +186,11 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements :param history_definition_id: The id of the access review history definition. Required. :type history_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,20 +206,18 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,8 +228,4 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py index c0104ae55246..0f28541ac38a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._access_review_history_definitions_operations import build_get_by_id_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +67,6 @@ def list( :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. 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 AccessReviewHistoryDefinition or the result of cls(response) :rtype: @@ -79,7 +81,7 @@ def list( ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,16 +92,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,14 +110,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -127,11 +126,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,22 +143,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions" - } - @distributed_trace_async async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,20 +169,18 @@ async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models. ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( history_definition_id=history_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,13 +190,9 @@ async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models. error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py index 90c547171108..182f74820db1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceContactedReviewersOperations: +class AccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -63,7 +66,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -78,7 +80,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,17 +91,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,14 +110,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -127,11 +126,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,7 +142,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py index 7b6e6c3cc8a2..c226281d371a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_decisions_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +71,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -83,7 +85,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,18 +96,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -133,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,7 +148,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py index 05e1a248f909..72046d02d115 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,26 +21,28 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -74,7 +77,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -89,7 +91,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +102,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +121,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -138,11 +137,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -171,12 +166,11 @@ async def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,21 +186,19 @@ async def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,16 +208,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload async def patch( @@ -252,7 +240,6 @@ async def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +251,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,11 +265,10 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +280,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -306,18 +292,15 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -342,7 +325,7 @@ async def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -350,16 +333,14 @@ async def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +350,9 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py index bf8e8e0ab3d8..9a4d4e46cca6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,14 +18,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, @@ -33,6 +32,10 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,12 +70,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +90,19 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,11 +113,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -129,12 +125,11 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -150,21 +145,19 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,11 +168,7 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -191,12 +180,11 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,21 +200,19 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -237,11 +223,7 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements @@ -253,12 +235,11 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,21 +255,19 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,11 +278,7 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -315,12 +290,11 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,20 +310,18 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +332,4 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py index 2f93b7d715eb..83a727e4d841 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,25 +20,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instances_assigned_for_my_approval_operations import ( build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,7 +73,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -85,7 +87,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,16 +98,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,14 +116,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -133,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -162,12 +157,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,20 +177,18 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,13 +198,9 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py index e7b6e5ab3458..1b8ef7d9b974 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,21 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +75,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -87,7 +89,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +119,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -136,11 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -165,12 +160,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,21 +180,19 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +202,12 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload async def create( @@ -243,7 +231,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -254,7 +241,7 @@ async def create( self, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -266,11 +253,10 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -281,7 +267,7 @@ async def create( self, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -291,18 +277,15 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. + AccessReviewInstanceProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or + IO[bytes] :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -327,7 +310,7 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, @@ -335,16 +318,14 @@ async def create( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -354,13 +335,9 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 784c30e2d082..90f36bdc4bf0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -64,7 +67,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -79,7 +81,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +92,13 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +109,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -126,11 +125,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,5 +141,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py index e2b57209e862..50e96bdf8072 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, @@ -37,11 +36,15 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +75,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -87,7 +89,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,16 +100,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +118,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -135,11 +134,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,22 +151,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,20 +177,18 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,16 +198,12 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -225,12 +213,11 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,20 +233,18 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,11 +255,7 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update_by_id( @@ -295,7 +276,6 @@ async def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -303,18 +283,22 @@ async def create_or_update_by_id( @overload async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -324,7 +308,7 @@ async def create_or_update_by_id( async def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -332,19 +316,15 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,23 +349,21 @@ async def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -395,16 +373,12 @@ async def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -414,12 +388,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -435,20 +408,18 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,8 +430,4 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py index 393af574b8e3..54fd1d5301cb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_12_01_preview.models.Operation] @@ -71,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +84,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -100,14 +100,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _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) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py index 3cf432e09ae3..d8b4b716ae62 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +19,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._scope_access_review_default_settings_operations import build_get_request, build_put_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewDefaultSettingsOperations: +class ScopeAccessReviewDefaultSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -58,12 +61,11 @@ async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSet :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,19 +81,17 @@ async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSet ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -101,14 +101,12 @@ async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSet error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore @overload async def put( @@ -129,7 +127,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -137,18 +134,17 @@ async def put( @overload async def put( - self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -156,25 +152,21 @@ async def put( @distributed_trace_async async def put( - self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,22 +191,20 @@ async def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -224,11 +214,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py index 3d5583c15b4f..bbbb8ecbb3e0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,23 +18,25 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_history_definition_instance_operations import ( build_generate_download_uri_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionInstanceOperations: +class ScopeAccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -67,12 +70,11 @@ async def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +90,19 @@ async def generate_download_uri( ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +112,9 @@ async def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_download_uri.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py index b08d5b0de42e..ae7b8fc9c7af 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_history_definition_instances_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionInstancesOperations: +class ScopeAccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -63,7 +66,6 @@ def list( :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: @@ -78,7 +80,7 @@ def list( ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,16 +91,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +109,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -126,11 +125,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,7 +141,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py index 051a192ce530..1fc6b67a626f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,24 +19,26 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_history_definition_operations import ( build_create_request, build_delete_by_id_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionOperations: +class ScopeAccessReviewHistoryDefinitionOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -77,7 +80,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -88,7 +90,7 @@ async def create( self, scope: str, history_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -100,11 +102,10 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -115,7 +116,7 @@ async def create( self, scope: str, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -125,19 +126,15 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,23 +159,21 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -188,16 +183,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -209,12 +200,11 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,20 +220,18 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,8 +242,4 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py index a3756ba1f04a..0c8358c3c475 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,25 +20,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_history_definitions_operations import ( build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionsOperations: +class ScopeAccessReviewHistoryDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -69,7 +72,6 @@ def list( :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. 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 AccessReviewHistoryDefinition or the result of cls(response) :rtype: @@ -84,7 +86,7 @@ def list( ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,16 +97,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -115,14 +115,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -132,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,8 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions"} - @distributed_trace_async async def get_by_id( self, scope: str, history_definition_id: str, **kwargs: Any @@ -161,12 +158,11 @@ async def get_by_id( :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -182,20 +178,18 @@ async def get_by_id( ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,13 +199,9 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py index 633523af6d35..54ec7d0a3d20 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_instance_contacted_reviewers_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewInstanceContactedReviewersOperations: +class ScopeAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -65,7 +68,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -80,7 +82,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,17 +93,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -112,14 +112,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -129,11 +128,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,7 +144,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py index be677521f8c8..90774922af49 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_instance_decisions_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewInstanceDecisionsOperations: +class ScopeAccessReviewInstanceDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,7 +73,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -85,7 +87,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,18 +98,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +118,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -135,11 +134,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,7 +150,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py index 69703cba78d3..cc4bd31d9f8e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_instance_operations import ( build_apply_decisions_request, build_record_all_decisions_request, @@ -34,6 +33,10 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,12 +73,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +93,19 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -116,11 +116,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def record_all_decisions( # pylint: disable=inconsistent-return-statements @@ -147,7 +143,6 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: @@ -159,7 +154,7 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -173,11 +168,10 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: @@ -189,7 +183,7 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.RecordAllDecisionsProperties, IO], + properties: Union[_models.RecordAllDecisionsProperties, IO[bytes]], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. @@ -201,18 +195,14 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type - or a IO type. Required. + or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -237,7 +227,7 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") - request = build_record_all_decisions_request( + _request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -245,16 +235,14 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, content=_content, - template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -265,11 +253,7 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - record_all_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -283,12 +267,11 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -304,21 +287,19 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -329,11 +310,7 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -347,12 +324,11 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -368,21 +344,19 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,11 +367,7 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements @@ -411,12 +381,11 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,21 +401,19 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -457,8 +424,4 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py index 098e7b1ea1af..1608a3bef2e7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,21 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +77,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -89,7 +91,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,17 +102,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +121,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -138,11 +137,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any @@ -171,12 +166,11 @@ async def get_by_id( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,21 +186,19 @@ async def get_by_id( ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,16 +208,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload async def create( @@ -252,7 +240,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +251,7 @@ async def create( scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,11 +265,10 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +280,7 @@ async def create( scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -306,18 +292,15 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. + AccessReviewInstanceProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or + IO[bytes] :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -342,7 +325,7 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -350,16 +333,14 @@ async def create( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +350,9 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py index dd70ad66685a..b08c52757ab6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scope_access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, @@ -37,11 +36,15 @@ build_stop_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewScheduleDefinitionsOperations: +class ScopeAccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -74,7 +77,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -89,7 +91,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,16 +102,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -120,14 +120,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -137,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,8 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} - @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any @@ -166,12 +163,11 @@ async def get_by_id( :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,20 +183,18 @@ async def get_by_id( ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +204,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -231,12 +221,11 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -252,20 +241,18 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,11 +263,7 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update_by_id( @@ -304,7 +287,6 @@ async def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -315,7 +297,7 @@ async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -327,11 +309,10 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -342,7 +323,7 @@ async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -352,19 +333,15 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -389,23 +366,21 @@ async def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -415,16 +390,12 @@ async def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -436,12 +407,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,20 +427,18 @@ async def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -481,8 +449,4 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py index 9d63f1c79913..74630a380e32 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantLevelAccessReviewInstanceContactedReviewersOperations: +class TenantLevelAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -63,7 +66,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -78,7 +80,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,16 +91,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,14 +109,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -126,11 +125,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,7 +141,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py index edfeb65e9e61..a0a68c93dd9f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py @@ -315,7 +315,7 @@ class AccessReviewDecisionIdentity(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -404,7 +404,7 @@ class AccessReviewDecisionInsightProperties(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of insight. Required. "userSignInInsight" :vartype type: str or @@ -638,12 +638,12 @@ def __init__( self.display_name_principal_display_name = None -class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): +class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): # pylint: disable=name-too-long """Service Principal Decision Target. 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -682,7 +682,7 @@ class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". @@ -716,12 +716,14 @@ def __init__(self, **kwargs: Any) -> None: self.user_principal_name = None -class AccessReviewDecisionUserSignInInsightProperties(AccessReviewDecisionInsightProperties): +class AccessReviewDecisionUserSignInInsightProperties( + AccessReviewDecisionInsightProperties +): # pylint: disable=name-too-long """User Decision Target. 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. + All required parameters must be populated in order to send to server. :ivar type: The type of insight. Required. "userSignInInsight" :vartype type: str or @@ -1125,7 +1127,7 @@ def __init__( self.user_principal_name = None -class AccessReviewHistoryDefinitionInstanceListResult(_serialization.Model): +class AccessReviewHistoryDefinitionInstanceListResult(_serialization.Model): # pylint: disable=name-too-long """List of Access Review History Instances. :ivar value: Access Review History Definition's Instance list. diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py index 635c42dbc02c..bbeaafbd2f09 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,12 +119,11 @@ def __init__(self, *args, **kwargs): def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,19 +139,17 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,16 +159,12 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload def put( @@ -182,7 +178,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -190,16 +185,15 @@ def put( @overload def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -207,23 +201,19 @@ def put( @distributed_trace def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,22 +238,20 @@ def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +261,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py index 431dba43d577..b4c379f2520c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_generate_download_uri_request( "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,7 +68,7 @@ def build_generate_download_uri_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewHistoryDefinitionInstanceOperations: +class AccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -97,12 +100,11 @@ def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -118,21 +120,19 @@ def generate_download_uri( ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,13 +142,9 @@ def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_download_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py index e3bc81edcfea..b1b93fde746f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(history_definition_id: str, subscription_id: str, **kwarg "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,7 +67,7 @@ def build_list_request(history_definition_id: str, subscription_id: str, **kwarg return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewHistoryDefinitionInstancesOperations: +class AccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -90,7 +93,6 @@ def list(self, history_definition_id: str, **kwargs: Any) -> Iterable["_models.A :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: @@ -105,7 +107,7 @@ def list(self, history_definition_id: str, **kwargs: Any) -> Iterable["_models.A ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -116,16 +118,14 @@ def list(self, history_definition_id: str, **kwargs: Any) -> Iterable["_models.A def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -136,14 +136,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -153,11 +152,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,7 +168,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py index 696f778cdd14..775698c43deb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_create_request(history_definition_id: str, subscription_id: str, **kwa "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_delete_by_id_request(history_definition_id: str, subscription_id: str, "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,7 +136,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -141,18 +143,22 @@ def create( @overload def create( - self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + history_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +168,7 @@ def create( def create( self, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -170,19 +176,15 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,23 +209,21 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,16 +233,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -252,12 +248,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :param history_definition_id: The id of the access review history definition. Required. :type history_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -273,20 +268,18 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -297,8 +290,4 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py index 031558519eec..ea5ae2a64c63 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +85,7 @@ def build_get_by_id_request(history_definition_id: str, subscription_id: str, ** "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +124,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. 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 AccessReviewHistoryDefinition or the result of cls(response) :rtype: @@ -136,7 +138,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -147,16 +149,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -167,14 +167,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -184,11 +183,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,22 +200,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions" - } - @distributed_trace def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -232,20 +226,18 @@ def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.Access ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( history_definition_id=history_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -255,13 +247,9 @@ def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.Access error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py index f26b7dd35419..8976b34f3e3b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_list_request(schedule_definition_id: str, id: str, subscription_id: st "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,7 +68,7 @@ def build_list_request(schedule_definition_id: str, id: str, subscription_id: st return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceContactedReviewersOperations: +class AccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -95,7 +98,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -110,7 +112,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,17 +123,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -142,14 +142,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -159,11 +158,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,7 +174,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py index fe0a8f1c6f7b..458c95347aef 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +107,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -119,7 +121,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,18 +132,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -152,14 +152,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -169,11 +168,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -185,7 +184,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py index 525e2d35e491..d18fd0a04220 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: s "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +120,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +133,7 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -165,7 +168,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -180,7 +182,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,17 +193,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -212,14 +212,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -229,11 +228,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -262,12 +257,11 @@ def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,21 +277,19 @@ def get_by_id( ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,16 +299,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload def patch( @@ -343,7 +331,6 @@ def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -355,7 +342,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,11 +356,10 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: @@ -385,7 +371,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -397,18 +383,15 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. + AccessReviewDecisionProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or + IO[bytes] :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -433,7 +416,7 @@ def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -441,16 +424,14 @@ def patch( 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,13 +441,9 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py index 6480468e873e..e2b0a284a20c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_stop_request(schedule_definition_id: str, id: str, subscription_id: st "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_reset_decisions_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +117,7 @@ def build_apply_decisions_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +148,7 @@ def build_send_reminders_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +176,7 @@ def build_accept_recommendations_request(schedule_definition_id: str, id: str, * "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,12 +217,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -235,21 +237,19 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,11 +260,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -276,12 +272,11 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,21 +292,19 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -322,11 +315,7 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -338,12 +327,11 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,21 +347,19 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,11 +370,7 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements @@ -400,12 +382,11 @@ def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,21 +402,19 @@ def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,11 +425,7 @@ def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -462,12 +437,11 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,20 +457,18 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,8 +479,4 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py index 490c4997b6fd..e2bed5e64756 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = N "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +85,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +96,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -126,7 +129,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -141,7 +143,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -152,16 +154,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -172,14 +172,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -189,11 +188,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,10 +205,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -218,12 +213,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,20 +233,18 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,13 +254,9 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py index 980b5e96f2d8..efba6b945981 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_i "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +120,7 @@ def build_create_request(schedule_definition_id: str, id: str, subscription_id: "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,7 +166,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -178,7 +180,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,17 +191,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -210,14 +210,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -227,11 +226,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,10 +243,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -256,12 +251,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,21 +271,19 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -301,16 +293,12 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload def create( @@ -334,7 +322,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -345,7 +332,7 @@ def create( self, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -357,11 +344,10 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -372,7 +358,7 @@ def create( self, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -382,18 +368,15 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. + AccessReviewInstanceProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or + IO[bytes] :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,7 +401,7 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, @@ -426,16 +409,14 @@ def create( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -445,13 +426,9 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 184634f92127..0698eddadef3 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRe return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -86,7 +89,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -101,7 +103,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,15 +114,13 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -131,14 +131,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -148,11 +147,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,5 +163,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py index 174c294924f2..9c2a3b41f468 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, * "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +114,7 @@ def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +145,7 @@ def build_create_or_update_by_id_request( "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +175,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,7 +186,7 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -212,7 +215,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -227,7 +229,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,16 +240,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -258,14 +258,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -275,11 +274,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,22 +291,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,20 +317,18 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, 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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -346,16 +338,12 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -365,12 +353,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,20 +373,18 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,11 +395,7 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update_by_id( @@ -435,7 +416,6 @@ def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -443,18 +423,22 @@ def create_or_update_by_id( @overload def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -464,7 +448,7 @@ def create_or_update_by_id( def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -472,19 +456,15 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -509,23 +489,21 @@ def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, 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.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,16 +513,12 @@ def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -554,12 +528,11 @@ def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,20 +548,18 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,8 +570,4 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py index 5153ed8f2e57..5f3b20c89609 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +82,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. - :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.authorization.v2021_12_01_preview.models.Operation] @@ -93,7 +95,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,14 +106,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -122,14 +122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -139,11 +138,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py index 42207206696a..477bbe7182ed 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +51,7 @@ def build_get_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,7 +76,7 @@ def build_put_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +89,7 @@ def build_put_request(scope: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewDefaultSettingsOperations: +class ScopeAccessReviewDefaultSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -112,12 +115,11 @@ def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -133,19 +135,17 @@ def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,14 +155,12 @@ def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore @overload def put( @@ -183,7 +181,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -191,18 +188,17 @@ def put( @overload def put( - self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: @@ -210,25 +206,21 @@ def put( @distributed_trace def put( - self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. + type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,22 +245,20 @@ def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -278,11 +268,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py index b87d3afdef57..775920f3e7bb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_generate_download_uri_request( "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,7 +68,7 @@ def build_generate_download_uri_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionInstanceOperations: +class ScopeAccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -99,12 +102,11 @@ def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,21 +122,19 @@ def generate_download_uri( ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,13 +144,9 @@ def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_download_uri.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py index 04bd6281d819..21c7a448c316 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(scope: str, history_definition_id: str, **kwargs: Any) -> "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,7 +67,7 @@ def build_list_request(scope: str, history_definition_id: str, **kwargs: Any) -> return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionInstancesOperations: +class ScopeAccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -94,7 +97,6 @@ def list( :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: @@ -109,7 +111,7 @@ def list( ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,16 +122,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -140,14 +140,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -157,11 +156,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +172,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py index 48311167b09c..96cf5924bb2d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_create_request(scope: str, history_definition_id: str, **kwargs: Any) "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_delete_by_id_request(scope: str, history_definition_id: str, **kwargs: "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +97,7 @@ def build_delete_by_id_request(scope: str, history_definition_id: str, **kwargs: return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionOperations: +class ScopeAccessReviewHistoryDefinitionOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -136,7 +139,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -147,7 +149,7 @@ def create( self, scope: str, history_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -159,11 +161,10 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -174,7 +175,7 @@ def create( self, scope: str, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -184,19 +185,15 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -221,23 +218,21 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -247,16 +242,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -268,12 +259,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,20 +279,18 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,8 +301,4 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py index 353d0b4774d0..b719ed190500 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +82,7 @@ def build_get_by_id_request(scope: str, history_definition_id: str, **kwargs: An "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +93,7 @@ def build_get_by_id_request(scope: str, history_definition_id: str, **kwargs: An return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionsOperations: +class ScopeAccessReviewHistoryDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -122,7 +125,6 @@ def list( :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. 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 AccessReviewHistoryDefinition or the result of cls(response) :rtype: @@ -137,7 +139,7 @@ def list( ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,16 +150,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -168,14 +168,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -185,11 +184,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,8 +201,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions"} - @distributed_trace def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. @@ -212,12 +209,11 @@ def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _m :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -233,20 +229,18 @@ def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _m ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -256,13 +250,9 @@ def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py index 1b43fcc8e090..73f527cb2c08 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_list_request(scope: str, schedule_definition_id: str, id: str, **kwarg "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,7 +68,7 @@ def build_list_request(scope: str, schedule_definition_id: str, id: str, **kwarg return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewInstanceContactedReviewersOperations: +class ScopeAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -97,7 +100,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -112,7 +114,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,17 +125,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -144,14 +144,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -161,11 +160,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -177,7 +176,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py index b7fb53ea5a5d..c561cb61654c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -69,7 +72,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewInstanceDecisionsOperations: +class ScopeAccessReviewInstanceDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -106,7 +109,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewDecision or the result of cls(response) :rtype: @@ -121,7 +123,7 @@ def list( ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,18 +134,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -154,14 +154,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -171,11 +170,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -187,7 +186,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py index 38813e0e8231..2ca4d9665d06 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_stop_request(scope: str, schedule_definition_id: str, id: str, **kwarg "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +86,7 @@ def build_record_all_decisions_request(scope: str, schedule_definition_id: str, "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +117,7 @@ def build_reset_decisions_request(scope: str, schedule_definition_id: str, id: s "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +146,7 @@ def build_apply_decisions_request(scope: str, schedule_definition_id: str, id: s "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +175,7 @@ def build_send_reminders_request(scope: str, schedule_definition_id: str, id: st "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,12 +218,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,21 +238,19 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,11 +261,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def record_all_decisions( # pylint: disable=inconsistent-return-statements @@ -292,7 +288,6 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: @@ -304,7 +299,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -318,11 +313,10 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: @@ -334,7 +328,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.RecordAllDecisionsProperties, IO], + properties: Union[_models.RecordAllDecisionsProperties, IO[bytes]], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. @@ -346,18 +340,14 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type - or a IO type. Required. + or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,7 +372,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") - request = build_record_all_decisions_request( + _request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -390,16 +380,14 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,11 +398,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - record_all_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -428,12 +412,11 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,21 +432,19 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -474,11 +455,7 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -492,12 +469,11 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -513,21 +489,19 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -538,11 +512,7 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements @@ -556,12 +526,11 @@ def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,21 +546,19 @@ def send_reminders( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -602,8 +569,4 @@ def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py index 260ac1c153f3..3c13810c8aab 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def build_list_request( "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +90,7 @@ def build_get_by_id_request(scope: str, schedule_definition_id: str, id: str, ** "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +120,7 @@ def build_create_request(scope: str, schedule_definition_id: str, id: str, **kwa "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,7 +168,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewInstance or the result of cls(response) :rtype: @@ -180,7 +182,7 @@ def list( ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,17 +193,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -212,14 +212,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -229,11 +228,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any @@ -262,12 +257,11 @@ def get_by_id( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,21 +277,19 @@ def get_by_id( ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,16 +299,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload def create( @@ -343,7 +331,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -355,7 +342,7 @@ def create( scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,11 +356,10 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: @@ -385,7 +371,7 @@ def create( scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -397,18 +383,15 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. + AccessReviewInstanceProperties type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or + IO[bytes] :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -433,7 +416,7 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -441,16 +424,14 @@ def create( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,13 +441,9 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py index daf22c9b80a3..adc2c8c6b9d8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +83,7 @@ def build_get_by_id_request(scope: str, schedule_definition_id: str, **kwargs: A "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +111,7 @@ def build_delete_by_id_request(scope: str, schedule_definition_id: str, **kwargs "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,7 +140,7 @@ def build_create_or_update_by_id_request(scope: str, schedule_definition_id: str "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,7 +170,7 @@ def build_stop_request(scope: str, schedule_definition_id: str, **kwargs: Any) - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +181,7 @@ def build_stop_request(scope: str, schedule_definition_id: str, **kwargs: Any) - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewScheduleDefinitionsOperations: +class ScopeAccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -211,7 +214,6 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. 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 AccessReviewScheduleDefinition or the result of cls(response) :rtype: @@ -226,7 +228,7 @@ def list( ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -237,16 +239,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +257,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -274,11 +273,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,8 +290,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} - @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any @@ -303,12 +300,11 @@ def get_by_id( :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,20 +320,18 @@ def get_by_id( ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,16 +341,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -368,12 +358,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -389,20 +378,18 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -413,11 +400,7 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update_by_id( @@ -441,7 +424,6 @@ def create_or_update_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -452,7 +434,7 @@ def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -464,11 +446,10 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +460,7 @@ def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -489,19 +470,15 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -526,23 +503,21 @@ def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,16 +527,12 @@ def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -573,12 +544,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -594,20 +564,18 @@ def stop( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,8 +586,4 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py index bba1797ba26a..31111d92165e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> H "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,7 +67,7 @@ def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> H return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class TenantLevelAccessReviewInstanceContactedReviewersOperations: +class TenantLevelAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -94,7 +97,6 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: @@ -109,7 +111,7 @@ def list( ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,16 +122,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -140,14 +140,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -157,11 +156,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +172,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_authorization_management_client.py index 048a0e100390..c40df895c5ee 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -69,7 +72,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -91,7 +112,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-04-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -111,12 +132,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_configuration.py index b501f5692f43..6d37f7bfe9ed 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_metadata.json index 1ded4f59232d..2098bac38b93 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deny_assignments": "DenyAssignmentsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_authorization_management_client.py index c742c42451a6..4af5c56fd3ee 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -69,7 +72,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -91,7 +112,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-04-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -111,12 +134,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_configuration.py index f778747ea8b4..82acf8509697 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_deny_assignments_operations.py index 11bc2ef51898..f24880f16a4f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_deny_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._deny_assignments_operations import ( build_get_by_id_request, build_get_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -96,7 +99,6 @@ def list_for_resource( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -108,7 +110,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,7 +121,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -128,12 +130,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -144,14 +144,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -161,11 +160,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -178,10 +177,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -202,7 +197,6 @@ def list_for_resource_group( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -214,7 +208,7 @@ def list_for_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,17 +219,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -246,14 +238,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -263,11 +254,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -280,10 +271,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. @@ -299,7 +286,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -311,7 +297,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -322,16 +308,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -342,14 +326,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -359,11 +342,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -376,8 +359,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - @distributed_trace_async async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. @@ -386,12 +367,11 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,20 +385,18 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -428,14 +406,12 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace_async async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: @@ -447,12 +423,11 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,19 +441,17 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,14 +461,12 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -516,7 +487,6 @@ def list_for_scope( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -528,7 +498,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -539,16 +509,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,14 +527,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -576,11 +543,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -592,5 +559,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_permissions_operations.py index 93f5baf144c1..fb643f997695 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +63,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As :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 Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] @@ -72,7 +74,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,16 +85,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -103,14 +103,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -120,11 +119,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,10 +136,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -164,7 +159,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] @@ -176,7 +170,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +181,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -195,12 +189,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -211,14 +203,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -228,11 +219,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,7 +235,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_provider_operations_metadata_operations.py index 938ae96af886..ea5d633a5870 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._provider_operations_metadata_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,12 +67,11 @@ async def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,20 +85,18 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,14 +106,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_models.ProviderOperationsMetadata"]: @@ -121,7 +119,6 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :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 ProviderOperationsMetadata or the result of cls(response) :rtype: @@ -134,7 +131,7 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -145,15 +142,13 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, 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) else: # make call to next link with the client's api-version @@ -164,14 +159,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -181,11 +175,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,5 +191,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_assignments_operations.py index b6070feb7f78..da24769dba72 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, @@ -42,6 +41,10 @@ build_list_for_subscription_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,7 +81,6 @@ def list_for_subscription( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -90,7 +92,7 @@ def list_for_subscription( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,17 +103,15 @@ def list_for_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_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) else: # make call to next link with the client's api-version @@ -122,14 +122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -139,11 +138,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -156,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -175,7 +170,6 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -187,7 +181,7 @@ def list_for_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,18 +192,16 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -220,14 +212,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -237,11 +228,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,10 +245,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource( self, @@ -287,7 +274,6 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -299,7 +285,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -310,7 +296,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, @@ -319,12 +305,10 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -335,14 +319,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -352,11 +335,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,10 +352,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -390,12 +369,11 @@ async def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,21 +387,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -433,14 +409,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def create( @@ -468,7 +442,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +452,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -496,11 +469,10 @@ async def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -511,7 +483,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. @@ -526,18 +498,14 @@ async def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -560,23 +528,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -586,19 +552,13 @@ async def create( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -616,12 +576,11 @@ async def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -635,21 +594,19 @@ async def delete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -661,14 +618,12 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -697,7 +652,6 @@ def list_for_scope( return paged role assignments following the skipToken passed. Only supported on provider level calls. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -709,7 +663,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,18 +674,16 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -742,14 +694,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -759,11 +710,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -776,8 +727,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace_async async def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -792,12 +741,11 @@ async def get_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -811,20 +759,18 @@ async def get_by_id( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -834,14 +780,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload async def create_by_id( @@ -865,7 +809,6 @@ async def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -873,7 +816,7 @@ async def create_by_id( @overload async def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -884,11 +827,10 @@ async def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -896,7 +838,10 @@ async def create_by_id( @distributed_trace_async async def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -907,18 +852,14 @@ async def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -941,22 +882,20 @@ async def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -966,19 +905,13 @@ async def create_by_id( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -993,12 +926,11 @@ async def delete_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1012,20 +944,18 @@ async def delete_by_id( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1037,11 +967,9 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_definitions_operations.py index 4531a6c139d4..7da50c46b1b9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_definitions_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,12 +72,11 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,20 +90,18 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,14 +113,12 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -130,12 +128,11 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,20 +146,18 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -172,14 +167,12 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload async def create_or_update( @@ -202,7 +195,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -213,7 +205,7 @@ async def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -225,11 +217,10 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -237,7 +228,11 @@ async def create_or_update( @distributed_trace_async async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -246,17 +241,13 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -279,23 +270,21 @@ async def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -305,14 +294,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: @@ -323,7 +310,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] @@ -335,7 +321,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -346,16 +332,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -366,14 +350,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -383,11 +366,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -400,8 +383,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -412,12 +393,11 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,19 +411,17 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -453,11 +431,9 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py index a25c36472046..2a505f4da49a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py @@ -956,7 +956,7 @@ class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=t 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. + All required parameters must be populated in order to send to server. :ivar scope: The role assignment scope. :vartype scope: str @@ -1269,7 +1269,7 @@ class RoleManagementPolicyRule(_serialization.Model): RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -1325,7 +1325,7 @@ def __init__( class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -1373,10 +1373,10 @@ def __init__( self.setting = setting -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): +class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): # pylint: disable=name-too-long """The role management policy authentication context rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -1434,7 +1434,7 @@ def __init__( class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy enablement rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -1487,7 +1487,7 @@ def __init__( class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -1545,7 +1545,7 @@ def __init__( class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_deny_assignments_operations.py index e3c38c4ba49e..e9b338b56359 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_deny_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,7 @@ def build_list_for_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,7 +108,7 @@ def build_list_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,7 +136,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,7 +163,7 @@ def build_get_request(scope: str, deny_assignment_id: str, **kwargs: Any) -> Htt "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +187,7 @@ def build_get_by_id_request(deny_assignment_id: str, **kwargs: Any) -> HttpReque "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,7 +211,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,7 +279,6 @@ def list_for_resource( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -288,7 +290,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,7 +301,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -308,12 +310,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) else: # make call to next link with the client's api-version @@ -324,14 +324,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -341,11 +340,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +357,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any @@ -382,7 +377,6 @@ def list_for_resource_group( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -394,7 +388,7 @@ def list_for_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,17 +399,15 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -426,14 +418,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -443,11 +434,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,10 +451,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. @@ -479,7 +466,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -491,7 +477,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -502,16 +488,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -522,14 +506,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -539,11 +522,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -556,8 +539,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - @distributed_trace def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. @@ -566,12 +547,11 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,20 +565,18 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,14 +586,12 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: @@ -627,12 +603,11 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,19 +621,17 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( deny_assignment_id=deny_assignment_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -668,14 +641,12 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -696,7 +667,6 @@ def list_for_scope( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. 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 DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] @@ -708,7 +678,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -719,16 +689,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -739,14 +707,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -756,11 +723,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -772,5 +739,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_permissions_operations.py index 5d68e5e0b826..d3c6eb3f8daf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_for_resource_group_request(resource_group_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +102,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,7 +140,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It :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 Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: @@ -148,7 +150,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -159,16 +161,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -179,14 +179,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -196,11 +195,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,10 +212,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -240,7 +235,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: @@ -251,7 +245,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +256,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -270,12 +264,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -286,14 +278,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -303,11 +294,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,7 +310,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_provider_operations_metadata_operations.py index fa030854e946..2e3f48d39e90 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_get_request(resource_provider_namespace: str, *, expand: str = "resour ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,12 +120,11 @@ def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -136,20 +138,18 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,14 +159,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_models.ProviderOperationsMetadata"]: @@ -174,7 +172,6 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :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 ProviderOperationsMetadata or the result of cls(response) :rtype: @@ -187,7 +184,7 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,15 +195,13 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, 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) else: # make call to next link with the client's api-version @@ -217,14 +212,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -234,11 +228,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -250,5 +244,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_assignments_operations.py index 5f8931ac23e9..249e4c56259a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_list_for_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +98,7 @@ def build_list_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,7 +147,7 @@ def build_list_for_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -175,7 +178,7 @@ def build_get_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +206,7 @@ def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -232,7 +235,7 @@ def build_delete_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -265,7 +268,7 @@ def build_list_for_scope_request( "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -295,7 +298,7 @@ def build_get_by_id_request(role_assignment_id: str, *, tenant_id: Optional[str] "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -322,7 +325,7 @@ def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRe "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -350,7 +353,7 @@ def build_delete_by_id_request( "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -395,7 +398,6 @@ def list_for_subscription( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -407,7 +409,7 @@ def list_for_subscription( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,17 +420,15 @@ def list_for_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_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) else: # make call to next link with the client's api-version @@ -439,14 +439,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -456,11 +455,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -473,10 +472,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any @@ -492,7 +487,6 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -504,7 +498,7 @@ def list_for_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -515,18 +509,16 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -537,14 +529,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -554,11 +545,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,10 +562,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource( self, @@ -604,7 +591,6 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -616,7 +602,7 @@ def list_for_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -627,7 +613,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, @@ -636,12 +622,10 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, 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) else: # make call to next link with the client's api-version @@ -652,14 +636,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -669,11 +652,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -686,10 +669,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -707,12 +686,11 @@ def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -726,21 +704,19 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -750,14 +726,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def create( @@ -785,7 +759,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -796,7 +769,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -813,11 +786,10 @@ def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -828,7 +800,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. @@ -843,18 +815,14 @@ def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -877,23 +845,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -903,19 +869,13 @@ def create( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -933,12 +893,11 @@ def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -952,21 +911,19 @@ def delete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -978,14 +935,12 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -1014,7 +969,6 @@ def list_for_scope( return paged role assignments following the skipToken passed. Only supported on provider level calls. 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 RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] @@ -1026,7 +980,7 @@ def list_for_scope( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1037,18 +991,16 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1059,14 +1011,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1076,11 +1027,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1093,8 +1044,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -1109,12 +1058,11 @@ def get_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1128,20 +1076,18 @@ def get_by_id( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1151,14 +1097,12 @@ 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("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload def create_by_id( @@ -1182,7 +1126,6 @@ def create_by_id( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -1190,7 +1133,7 @@ def create_by_id( @overload def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -1201,11 +1144,10 @@ def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: @@ -1213,7 +1155,10 @@ def create_by_id( @distributed_trace def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. @@ -1224,18 +1169,14 @@ def create_by_id( Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1258,22 +1199,20 @@ def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1283,19 +1222,13 @@ def create_by_id( 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("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - @distributed_trace def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -1310,12 +1243,11 @@ def delete_by_id( :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1329,20 +1261,18 @@ def delete_by_id( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1354,11 +1284,9 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_definitions_operations.py index a5f86335ed00..4e4ffbb8519b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +79,7 @@ def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> Htt "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +105,7 @@ def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +131,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -154,7 +157,7 @@ def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,12 +196,11 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,20 +214,18 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -237,14 +237,12 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -254,12 +252,11 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -273,20 +270,18 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -296,14 +291,12 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload def create_or_update( @@ -326,7 +319,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -337,7 +329,7 @@ def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -349,11 +341,10 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -361,7 +352,11 @@ def create_or_update( @distributed_trace def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -370,17 +365,13 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,23 +394,21 @@ def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,14 +418,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: @@ -447,7 +434,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] @@ -459,7 +445,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,16 +456,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -490,14 +474,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -507,11 +490,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -524,8 +507,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -536,12 +517,11 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -555,19 +535,17 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,11 +555,9 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_authorization_management_client.py index fc34514cd200..2194631f46ce 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -46,7 +49,25 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -59,7 +80,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-04-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +100,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_configuration.py index d5cab6d0c942..364afdb63edb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-04-01-preview") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_metadata.json index a256424cc2ad..c941c4dc392c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -88,8 +88,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignment_schedule_requests": "RoleAssignmentScheduleRequestsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_authorization_management_client.py index cf6c398f9abd..2c456eedf41d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -46,7 +49,25 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -59,7 +80,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-04-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +102,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_configuration.py index 4682afc08b7d..d80a085b31d0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-04-01-preview") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py index ca3e5a81d474..5fe3ba0b084b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_assignment_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -37,6 +36,10 @@ build_validate_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -90,7 +93,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +103,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -120,11 +122,10 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -135,7 +136,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -152,18 +153,14 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,23 +185,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,16 +208,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -235,12 +226,11 @@ async def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,20 +246,18 @@ async def get( ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -278,16 +266,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -305,7 +289,6 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. 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 RoleAssignmentScheduleRequest or the result of cls(response) :rtype: @@ -320,7 +303,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,16 +314,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -351,14 +332,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -368,11 +348,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,8 +364,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any @@ -397,12 +375,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,20 +395,18 @@ async def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -441,11 +416,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def validate( @@ -470,7 +441,6 @@ async def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -481,7 +451,7 @@ async def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -494,11 +464,10 @@ async def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -509,7 +478,7 @@ async def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Validates a new role assignment schedule request. @@ -520,18 +489,14 @@ async def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -556,23 +521,21 @@ async def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -581,13 +544,9 @@ async def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py index 530046bd23c0..80cfbb8b6280 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -37,11 +36,15 @@ build_validate_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -90,7 +93,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +103,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -120,11 +122,10 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -135,7 +136,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -152,18 +153,15 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or + IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,23 +186,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,16 +209,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -235,12 +227,11 @@ async def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,20 +247,18 @@ async def get( ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -278,16 +267,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -305,7 +290,6 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. 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 RoleEligibilityScheduleRequest or the result of cls(response) :rtype: @@ -320,7 +304,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,16 +315,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -351,14 +333,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -368,11 +349,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,8 +365,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any @@ -397,12 +376,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,20 +396,18 @@ async def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -441,11 +417,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def validate( @@ -470,7 +442,6 @@ async def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -481,7 +452,7 @@ async def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -494,11 +465,10 @@ async def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -509,7 +479,7 @@ async def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Validates a new role eligibility schedule request. @@ -520,18 +490,15 @@ async def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or + IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -556,23 +523,21 @@ async def validate( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -581,13 +546,9 @@ async def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_models_py3.py index ae6cb622ab14..0d5d546b977b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_models_py3.py @@ -479,7 +479,7 @@ def __init__( self.next_link = next_link -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long """Schedule info of the role assignment schedule. :ivar start_date_time: Start DateTime of the role assignment schedule. @@ -506,14 +506,16 @@ def __init__( :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role assignment schedule. :paramtype expiration: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration # pylint: disable=line-too-long """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long """Expiration of the role assignment schedule. :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", @@ -554,7 +556,7 @@ def __init__( self.duration = duration -class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): +class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long """Ticket Info of the role assignment. :ivar ticket_number: Ticket number for the role assignment. @@ -838,7 +840,7 @@ def __init__( self.next_link = next_link -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long """Schedule info of the role eligibility schedule. :ivar start_date_time: Start DateTime of the role eligibility schedule. @@ -865,14 +867,16 @@ def __init__( :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role eligibility schedule. :paramtype expiration: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration # pylint: disable=line-too-long """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long """Expiration of the role eligibility schedule. :ivar type: Type of the role eligibility schedule expiration. Known values are: @@ -913,7 +917,7 @@ def __init__( self.duration = duration -class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): +class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long """Ticket Info of the role eligibility. :ivar ticket_number: Ticket number for the role eligibility. diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_assignment_schedule_requests_operations.py index fdb871273b10..16fa2b96ad42 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_create_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +92,7 @@ def build_get_request(scope: str, role_assignment_schedule_request_name: str, ** ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +116,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -145,7 +148,7 @@ def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -176,7 +179,7 @@ def build_validate_request(scope: str, role_assignment_schedule_request_name: st ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -238,7 +241,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -249,7 +251,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -268,11 +270,10 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +284,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -300,18 +301,14 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,23 +333,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,16 +356,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -383,12 +374,11 @@ def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,20 +394,18 @@ def get( ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -426,16 +414,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -453,7 +437,6 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. 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 RoleAssignmentScheduleRequest or the result of cls(response) :rtype: @@ -468,7 +451,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -479,16 +462,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -499,14 +480,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -516,11 +496,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -532,8 +512,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any @@ -545,12 +523,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,20 +543,18 @@ def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -589,11 +564,7 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def validate( @@ -618,7 +589,6 @@ def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -629,7 +599,7 @@ def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -642,11 +612,10 @@ def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -657,7 +626,7 @@ def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Validates a new role assignment schedule request. @@ -668,18 +637,14 @@ def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -704,23 +669,21 @@ def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -729,13 +692,9 @@ def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_eligibility_schedule_requests_operations.py index c1665930d929..fd6e5dab7c6b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +60,7 @@ def build_create_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +92,7 @@ def build_get_request(scope: str, role_eligibility_schedule_request_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +116,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -145,7 +148,7 @@ def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -176,7 +179,7 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -189,7 +192,7 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -238,7 +241,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -249,7 +251,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -268,11 +270,10 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +284,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -300,18 +301,15 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or + IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,23 +334,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,16 +357,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -383,12 +375,11 @@ def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,20 +395,18 @@ def get( ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -426,16 +415,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -453,7 +438,6 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. 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 RoleEligibilityScheduleRequest or the result of cls(response) :rtype: @@ -468,7 +452,7 @@ def list_for_scope( ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -479,16 +463,14 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -499,14 +481,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -516,11 +497,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -532,8 +513,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any @@ -545,12 +524,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,20 +544,18 @@ def cancel( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -589,11 +565,7 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def validate( @@ -618,7 +590,6 @@ def validate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -629,7 +600,7 @@ def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -642,11 +613,10 @@ def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: @@ -657,7 +627,7 @@ def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Validates a new role eligibility schedule request. @@ -668,18 +638,15 @@ def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or + IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -704,23 +671,21 @@ def validate( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -729,13 +694,9 @@ def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_authorization_management_client.py index 58368cbfc3bf..4a312e3d335c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -54,7 +57,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -67,7 +88,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -87,12 +108,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_configuration.py index 81e24c62142a..97ab6407bbe7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_metadata.json index a704fb3cd3fa..3d6ff218225b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_public_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "permissions": "PermissionsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_authorization_management_client.py index 2e673e62c793..96e52669774a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -54,7 +57,25 @@ def __init__( self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -67,7 +88,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -87,12 +110,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_configuration.py index bb2c60526bea..c7bc80b6dd97 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py index 6427bc44c427..281db05c22d4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +63,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As :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 Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] @@ -74,7 +76,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,16 +87,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -105,14 +105,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -122,11 +121,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -139,10 +138,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -166,7 +161,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] @@ -180,7 +174,7 @@ def list_for_resource( ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,7 +185,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -199,12 +193,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -215,14 +207,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -232,11 +223,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -248,7 +239,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py index e29e62d7fb75..75eea0395a47 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._role_definitions_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,12 +76,11 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,20 +96,18 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,14 +119,12 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -140,12 +138,11 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,20 +158,18 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,14 +179,12 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload async def create_or_update( @@ -218,7 +211,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -229,7 +221,7 @@ async def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -245,11 +237,10 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -257,7 +248,11 @@ async def create_or_update( @distributed_trace_async async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -270,18 +265,14 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. + a IO[bytes] type. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,23 +297,21 @@ async def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,14 +321,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: @@ -354,7 +341,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] @@ -368,7 +354,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -379,16 +365,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -399,14 +383,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -416,11 +399,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -433,8 +416,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -445,12 +426,11 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,19 +446,17 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,11 +466,9 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_models_py3.py index dbd980877d8d..5d8d78dfae2c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_models_py3.py @@ -534,7 +534,7 @@ class RoleManagementPolicyRule(_serialization.Model): RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -592,7 +592,7 @@ def __init__( class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -642,10 +642,10 @@ def __init__( self.setting = setting -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): +class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): # pylint: disable=name-too-long """The role management policy authentication context rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -705,7 +705,7 @@ def __init__( class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy enablement rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -760,7 +760,7 @@ def __init__( class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str @@ -820,7 +820,7 @@ def __init__( class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The id of the rule. :vartype id: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py index bbebc9f28537..43193a5d132e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +58,7 @@ def build_list_for_resource_group_request(resource_group_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +102,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,7 +140,6 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It :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 Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] @@ -151,7 +153,7 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,16 +164,14 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -182,14 +182,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -199,11 +198,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,10 +215,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -243,7 +238,6 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] @@ -257,7 +251,7 @@ def list_for_resource( ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -268,7 +262,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -276,12 +270,10 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -292,14 +284,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -309,11 +300,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -325,7 +316,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py index f214db91e563..046753a0a3d2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +79,7 @@ def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> Htt "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +105,7 @@ def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +131,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -154,7 +157,7 @@ def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -197,12 +200,11 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,20 +220,18 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -243,14 +243,12 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -264,12 +262,11 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -285,20 +282,18 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -308,14 +303,12 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload def create_or_update( @@ -342,7 +335,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -353,7 +345,7 @@ def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,11 +361,10 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -381,7 +372,11 @@ def create_or_update( @distributed_trace def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -394,18 +389,14 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. + a IO[bytes] type. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -430,23 +421,21 @@ def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,14 +445,12 @@ 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("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: @@ -478,7 +465,6 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. 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 RoleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] @@ -492,7 +478,7 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,16 +489,14 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -523,14 +507,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -540,11 +523,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -557,8 +540,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -569,12 +550,11 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,19 +570,17 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -612,11 +590,9 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py index b1dfd0af0d72..844ef3642735 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -62,7 +65,25 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -84,7 +105,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -104,12 +125,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AuthorizationManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py index 033d7e5798b5..1da6f0c09543 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-08-01-preview") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_metadata.json index 53b46ccb1488..6326913a0105 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._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\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -88,8 +88,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "alerts": "AlertsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 List, cast - -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) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_version.py index 77f53a3589c6..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py index ea3406cd35a0..c20b86e2f038 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -62,7 +65,25 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -84,7 +105,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -104,12 +127,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AuthorizationManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py index 278d20daec1f..1eb745efa195 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AuthorizationManagementClientConfiguration(Configuration): # pylint: disa """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-08-01-preview") if credential is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py index d9f81bb3f78b..8c1abddcb7f6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,21 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._alert_configurations_operations import ( build_get_request, build_list_for_scope_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,12 +76,11 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertCo :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,20 +96,18 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertCo ) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -116,14 +116,12 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertCo map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertConfiguration", pipeline_response) + deserialized = self._deserialize("AlertConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return deserialized # type: ignore @overload async def update( # pylint: disable=inconsistent-return-statements @@ -146,7 +144,6 @@ async def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: @@ -154,7 +151,7 @@ async def update( # pylint: disable=inconsistent-return-statements @overload async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. @@ -163,11 +160,10 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: @@ -175,7 +171,7 @@ async def update( # pylint: disable=inconsistent-return-statements @distributed_trace_async async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any + self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO[bytes]], **kwargs: Any ) -> None: """Update an alert configuration. @@ -184,17 +180,14 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type - or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or + IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,23 +212,21 @@ async def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "AlertConfiguration") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -245,9 +236,7 @@ async def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertConfiguration"]: @@ -255,7 +244,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al :param scope: The scope of the alert configuration. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] @@ -269,7 +257,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al ) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -280,15 +268,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -299,14 +285,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) @@ -316,11 +301,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -331,5 +316,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py index 2b61202b6850..d7fecd27801f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._alert_definitions_operations import build_get_request, build_list_for_scope_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,12 +71,11 @@ async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _mod :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,20 +91,18 @@ async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _mod ) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_definition_id=alert_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -111,16 +111,12 @@ async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _mod map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertDefinition", pipeline_response) + deserialized = self._deserialize("AlertDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertDefinition"]: @@ -128,7 +124,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al :param scope: The scope of the alert definition. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] @@ -142,7 +137,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al ) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,15 +148,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -172,14 +165,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) @@ -189,11 +181,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,5 +196,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py index 8d81b33abf64..6ed2b4be767d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,21 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._alert_incidents_operations import ( build_get_request, build_list_for_scope_request, build_remediate_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,12 +77,11 @@ async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,21 +97,19 @@ async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: ) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,16 +118,12 @@ async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertIncident", pipeline_response) + deserialized = self._deserialize("AlertIncident", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncIterable["_models.AlertIncident"]: @@ -137,7 +133,6 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncItera :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] @@ -151,7 +146,7 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncItera ) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,16 +157,14 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncItera def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -182,14 +175,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) @@ -199,11 +191,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,10 +207,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" - } - @distributed_trace_async async def remediate( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any @@ -231,12 +219,11 @@ async def remediate( # pylint: disable=inconsistent-return-statements :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -252,21 +239,19 @@ async def remediate( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_remediate_request( + _request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, - template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,8 +261,4 @@ async def remediate( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - remediate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py index 66abb7247b37..81fc3974904e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._alert_operation_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,12 +62,11 @@ async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.Ale :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,20 +82,18 @@ async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.Ale ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, operation_id=operation_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -102,11 +102,9 @@ async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.Ale map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py index 309ec8b6fca5..9c04d1df7031 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._alerts_operations import ( build_get_request, build_list_for_scope_request, @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,12 +81,11 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,20 +101,18 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: ) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,14 +121,12 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Alert", pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return deserialized # type: ignore @overload async def update( # pylint: disable=inconsistent-return-statements @@ -149,7 +149,6 @@ async def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: @@ -157,7 +156,7 @@ async def update( # pylint: disable=inconsistent-return-statements @overload async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. @@ -166,11 +165,10 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: @@ -178,7 +176,7 @@ async def update( # pylint: disable=inconsistent-return-statements @distributed_trace_async async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any + self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO[bytes]], **kwargs: Any ) -> None: """Update an alert. @@ -186,17 +184,14 @@ async def update( # pylint: disable=inconsistent-return-statements :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str - :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Parameters for the alert. Is either a Alert type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -221,23 +216,21 @@ async def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "Alert") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -247,9 +240,7 @@ async def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: @@ -257,7 +248,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] @@ -271,7 +261,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al ) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -282,15 +272,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -301,14 +289,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) @@ -318,11 +305,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -334,10 +321,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} - - async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -351,43 +336,42 @@ async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _m api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_request( + _request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _refresh_initial.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return deserialized # type: ignore @distributed_trace_async async def begin_refresh( @@ -399,14 +383,6 @@ async def begin_refresh( :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_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 AlertOperationResult or the result of cls(response) :rtype: @@ -433,6 +409,7 @@ async def begin_refresh( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -440,9 +417,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -454,20 +431,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return AsyncLROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -481,40 +456,41 @@ async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.Alert api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_all_request( + _request = build_refresh_all_request( scope=scope, api_version=api_version, - template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return deserialized # type: ignore @distributed_trace_async async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_models.AlertOperationResult]: @@ -522,14 +498,6 @@ async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_ :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: @@ -550,6 +518,7 @@ async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_ raw_result = await self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -557,9 +526,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -571,12 +540,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return AsyncLROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py index ba2f22ba8cb7..60eb5e8422b2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py @@ -198,7 +198,7 @@ class AlertConfigurationProperties(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str @@ -433,7 +433,7 @@ class AlertIncidentProperties(_serialization.Model): TooManyOwnersAssignedToResourceAlertIncidentProperties, TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str @@ -538,12 +538,14 @@ def __init__(self, **kwargs: Any) -> None: self.resource_location = None -class AzureRolesAssignedOutsidePimAlertConfigurationProperties(AlertConfigurationProperties): +class AzureRolesAssignedOutsidePimAlertConfigurationProperties( + AlertConfigurationProperties +): # pylint: disable=name-too-long """The Azure roles assigned outside PIM alert configuration properties. 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. + All required parameters must be populated in order to send to server. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str @@ -585,12 +587,12 @@ def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: class AzureRolesAssignedOutsidePimAlertIncidentProperties( AlertIncidentProperties -): # pylint: disable=too-many-instance-attributes +): # pylint: disable=too-many-instance-attributes,name-too-long """Azure roles assigned outside PIM alert incident properties. 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. + All required parameters must be populated in order to send to server. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str @@ -690,12 +692,12 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, self.message = message -class DuplicateRoleCreatedAlertConfigurationProperties(AlertConfigurationProperties): +class DuplicateRoleCreatedAlertConfigurationProperties(AlertConfigurationProperties): # pylint: disable=name-too-long """The duplicate role created alert configuration. 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. + All required parameters must be populated in order to send to server. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str @@ -735,12 +737,12 @@ def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: self.alert_configuration_type: str = "DuplicateRoleCreatedAlertConfiguration" -class DuplicateRoleCreatedAlertIncidentProperties(AlertIncidentProperties): +class DuplicateRoleCreatedAlertIncidentProperties(AlertIncidentProperties): # pylint: disable=name-too-long """Duplicate role created alert incident properties. 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. + All required parameters must be populated in order to send to server. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str @@ -775,12 +777,14 @@ def __init__(self, **kwargs: Any) -> None: self.reason = None -class TooManyOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): +class TooManyOwnersAssignedToResourceAlertConfigurationProperties( + AlertConfigurationProperties +): # pylint: disable=name-too-long """Too many owners assigned to resource alert configuration properties. 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. + All required parameters must be populated in order to send to server. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str @@ -846,12 +850,12 @@ def __init__( ) -class TooManyOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): +class TooManyOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): # pylint: disable=name-too-long """Too many owners assigned to resource alert incident properties. 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. + All required parameters must be populated in order to send to server. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str @@ -881,12 +885,14 @@ def __init__(self, **kwargs: Any) -> None: self.assignee_type = None -class TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): +class TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties( + AlertConfigurationProperties +): # pylint: disable=name-too-long """Too many permanent owners assigned to resource alert configuration properties. 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. + All required parameters must be populated in order to send to server. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str @@ -952,12 +958,14 @@ def __init__( ) -class TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): +class TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties( + AlertIncidentProperties +): # pylint: disable=name-too-long """Too many permanent owners assigned to resource alert incident properties. 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. + All required parameters must be populated in order to send to server. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py index 5685979c2f3e..367fdfc9b08c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +56,7 @@ def build_get_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +84,7 @@ def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpReques "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +110,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -152,12 +155,11 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfigur :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,20 +175,18 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfigur ) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -195,14 +195,12 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfigur map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertConfiguration", pipeline_response) + deserialized = self._deserialize("AlertConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return deserialized # type: ignore @overload def update( # pylint: disable=inconsistent-return-statements @@ -225,7 +223,6 @@ def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: @@ -233,7 +230,7 @@ def update( # pylint: disable=inconsistent-return-statements @overload def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. @@ -242,11 +239,10 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: @@ -254,7 +250,7 @@ def update( # pylint: disable=inconsistent-return-statements @distributed_trace def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any + self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO[bytes]], **kwargs: Any ) -> None: """Update an alert configuration. @@ -263,17 +259,14 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type - or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or + IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,23 +291,21 @@ def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "AlertConfiguration") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,9 +315,7 @@ def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertConfiguration"]: @@ -334,7 +323,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertCo :param scope: The scope of the alert configuration. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] @@ -348,7 +336,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertCo ) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,15 +347,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertCo def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -378,14 +364,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) @@ -395,11 +380,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,5 +395,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py index c6975619eab0..5c0cf7fe85f4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_get_request(scope: str, alert_definition_id: str, **kwargs: Any) -> Ht "alertDefinitionId": _SERIALIZER.url("alert_definition_id", alert_definition_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +79,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,12 +124,11 @@ def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.Al :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -142,20 +144,18 @@ def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.Al ) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_definition_id=alert_definition_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,16 +164,12 @@ def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.Al map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertDefinition", pipeline_response) + deserialized = self._deserialize("AlertDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDefinition"]: @@ -181,7 +177,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDe :param scope: The scope of the alert definition. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] @@ -195,7 +190,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDe ) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,15 +201,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDe def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -225,14 +218,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) @@ -242,11 +234,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,5 +249,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py index 3b5931f1527a..2a52045070e2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def build_get_request(scope: str, alert_id: str, alert_incident_id: str, **kwarg "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +84,7 @@ def build_list_for_scope_request(scope: str, alert_id: str, **kwargs: Any) -> Ht "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,7 +113,7 @@ def build_remediate_request(scope: str, alert_id: str, alert_incident_id: str, * "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,12 +160,11 @@ def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,21 +180,19 @@ def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) ) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,16 +201,12 @@ def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertIncident", pipeline_response) + deserialized = self._deserialize("AlertIncident", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable["_models.AlertIncident"]: @@ -220,7 +216,6 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable[" :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] @@ -234,7 +229,7 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable[" ) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,16 +240,14 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable[" def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -265,14 +258,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) @@ -282,11 +274,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -298,10 +290,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" - } - @distributed_trace def remediate( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any @@ -314,12 +302,11 @@ def remediate( # pylint: disable=inconsistent-return-statements :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,21 +322,19 @@ def remediate( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_remediate_request( + _request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, - template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -359,8 +344,4 @@ def remediate( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - remediate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py index 6677021599f0..9c90889e167d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_get_request(scope: str, operation_id: str, **kwargs: Any) -> HttpReque "operationId": _SERIALIZER.url("operation_id", operation_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,12 +92,11 @@ def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOper :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,20 +112,18 @@ def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOper ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, operation_id=operation_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -132,11 +132,9 @@ def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOper map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py index 04c84dc29506..07f7d50f65f7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +58,7 @@ def build_get_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +84,7 @@ def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpReques "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,7 +110,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +137,7 @@ def build_refresh_request(scope: str, alert_id: str, **kwargs: Any) -> HttpReque "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -156,7 +161,7 @@ def build_refresh_all_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -200,12 +205,11 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -221,20 +225,18 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: ) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -243,14 +245,12 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Alert", pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return deserialized # type: ignore @overload def update( # pylint: disable=inconsistent-return-statements @@ -273,7 +273,6 @@ def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: @@ -281,7 +280,7 @@ def update( # pylint: disable=inconsistent-return-statements @overload def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. @@ -290,11 +289,10 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: @@ -302,7 +300,7 @@ def update( # pylint: disable=inconsistent-return-statements @distributed_trace def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any + self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO[bytes]], **kwargs: Any ) -> None: """Update an alert. @@ -310,17 +308,14 @@ def update( # pylint: disable=inconsistent-return-statements :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str - :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Parameters for the alert. Is either a Alert type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -345,23 +340,21 @@ def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "Alert") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_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) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -371,9 +364,7 @@ def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"]: @@ -381,7 +372,6 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"] :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] @@ -395,7 +385,7 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"] ) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,15 +396,13 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"] def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -425,14 +413,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) @@ -442,11 +429,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,10 +445,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} - - def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -475,43 +460,42 @@ def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models. api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_request( + _request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _refresh_initial.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return deserialized # type: ignore @distributed_trace def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: @@ -521,14 +505,6 @@ def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_ :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_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 AlertOperationResult or the result of cls(response) :rtype: @@ -555,6 +531,7 @@ def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_ params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -562,9 +539,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -576,20 +553,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return LROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + def _refresh_all_initial(self, scope: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -603,40 +578,41 @@ def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperat api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_all_request( + _request = build_refresh_all_request( scope=scope, api_version=api_version, - template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return deserialized # type: ignore @distributed_trace def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: @@ -644,14 +620,6 @@ def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.Aler :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: @@ -672,6 +640,7 @@ def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.Aler raw_result = self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -679,9 +648,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -693,12 +662,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return LROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py index 6b2656137037..e1c79027048e 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py index 7cf4c74f39aa..e32efb3268c8 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py index 8c832da5bdf7..f6b1880483a4 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py index 8bf0ac555760..45ff58e9474a 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py index 0406575e2e6a..08d90f00e4e6 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py index 39d6ac8f0b11..d2063e8dc32d 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py index 473ed4991a81..424dc03e9b07 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py index 1250e4947513..1c7be0db6d57 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py index 0b9782cadbff..531ecfa2bb2e 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py index 7099bb62050d..9a570e314353 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py index 4e4cb20f687e..d824f3ff7a25 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py index 31d5ddb37f83..91cc8a649813 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py index 344bd2f600e6..dc8900124ebd 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_name.py index e46ca94e24e6..57256c9c9bad 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_name.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_name.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py index 79724354e685..be011d1212e7 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py index b571ac6a53ad..1239eab90c2b 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py index 0bf104c5c3f6..3c311000d255 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py index 0349481e954e..52b2ac05633f 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py index 3065d4fd2aa6..bceb363a97c8 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py index f1d6ec361703..3b9c70fef2b7 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py index 95346f257c47..180e33171af9 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py index e7520e7b690a..c4f49b308601 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py index 10593e632922..facbb6a9e39b 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py index 03de94e5fed0..370279d8ac3b 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py index afca98926b25..3991aa6d249b 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py index b83a8d4ffe33..c253d4ca4461 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/conftest.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/conftest.py new file mode 100644 index 000000000000..f146cd58fd67 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/conftest.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + authorizationmanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + authorizationmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + authorizationmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + authorizationmanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=authorizationmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=authorizationmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=authorizationmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=authorizationmanagement_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations.py new file mode 100644 index 000000000000..a97e5054a69b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementDenyAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_resource(self, resource_group): + response = self.client.deny_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_resource_group(self, resource_group): + response = self.client.deny_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.deny_assignments.list( + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.deny_assignments.get( + scope="str", + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_id(self, resource_group): + response = self.client.deny_assignments.get_by_id( + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_scope(self, resource_group): + response = self.client.deny_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations_async.py new file mode 100644 index 000000000000..fe3453a6891b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementDenyAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_resource(self, resource_group): + response = self.client.deny_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_resource_group(self, resource_group): + response = self.client.deny_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.deny_assignments.list( + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.deny_assignments.get( + scope="str", + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_id(self, resource_group): + response = await self.client.deny_assignments.get_by_id( + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_scope(self, resource_group): + response = self.client.deny_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations.py new file mode 100644 index 000000000000..b63fde4aceb2 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementPermissionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_resource_group(self, resource_group): + response = self.client.permissions.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_resource(self, resource_group): + response = self.client.permissions.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations_async.py new file mode 100644 index 000000000000..b241ee24bd3a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations_async.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementPermissionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_resource_group(self, resource_group): + response = self.client.permissions.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_resource(self, resource_group): + response = self.client.permissions.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations.py new file mode 100644 index 000000000000..f125de6349e7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementProviderOperationsMetadataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.provider_operations_metadata.get( + resource_provider_namespace="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.provider_operations_metadata.list( + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations_async.py new file mode 100644 index 000000000000..e255cd0897ae --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations_async.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementProviderOperationsMetadataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.provider_operations_metadata.get( + resource_provider_namespace="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.provider_operations_metadata.list( + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations.py new file mode 100644 index 000000000000..c0988bc56a41 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations.py @@ -0,0 +1,162 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_subscription(self, resource_group): + response = self.client.role_assignments.list_for_subscription( + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_resource_group(self, resource_group): + response = self.client.role_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_resource(self, resource_group): + response = self.client.role_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.role_assignments.get( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.role_assignments.create( + scope="str", + role_assignment_name="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "User", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.role_assignments.delete( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_for_scope(self, resource_group): + response = self.client.role_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_id(self, resource_group): + response = self.client.role_assignments.get_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_by_id(self, resource_group): + response = self.client.role_assignments.create_by_id( + role_assignment_id="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "User", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete_by_id(self, resource_group): + response = self.client.role_assignments.delete_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations_async.py new file mode 100644 index 000000000000..74f78114dd3b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations_async.py @@ -0,0 +1,163 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_subscription(self, resource_group): + response = self.client.role_assignments.list_for_subscription( + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_resource_group(self, resource_group): + response = self.client.role_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_resource(self, resource_group): + response = self.client.role_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.role_assignments.get( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.role_assignments.create( + scope="str", + role_assignment_name="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "User", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.role_assignments.delete( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_for_scope(self, resource_group): + response = self.client.role_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_id(self, resource_group): + response = await self.client.role_assignments.get_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_by_id(self, resource_group): + response = await self.client.role_assignments.create_by_id( + role_assignment_id="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "User", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete_by_id(self, resource_group): + response = await self.client.role_assignments.delete_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations.py new file mode 100644 index 000000000000..f54392a3e310 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.role_definitions.delete( + scope="str", + role_definition_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.role_definitions.get( + scope="str", + role_definition_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.role_definitions.create_or_update( + scope="str", + role_definition_id="str", + role_definition={ + "assignableScopes": ["str"], + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "name": "str", + "permissions": [ + {"actions": ["str"], "dataActions": ["str"], "notActions": ["str"], "notDataActions": ["str"]} + ], + "roleName": "str", + "type": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.role_definitions.list( + scope="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_id(self, resource_group): + response = self.client.role_definitions.get_by_id( + role_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations_async.py new file mode 100644 index 000000000000..b98170658a9b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations_async.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.role_definitions.delete( + scope="str", + role_definition_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.role_definitions.get( + scope="str", + role_definition_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.role_definitions.create_or_update( + scope="str", + role_definition_id="str", + role_definition={ + "assignableScopes": ["str"], + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "name": "str", + "permissions": [ + {"actions": ["str"], "dataActions": ["str"], "notActions": ["str"], "notDataActions": ["str"]} + ], + "roleName": "str", + "type": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.role_definitions.list( + scope="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_id(self, resource_group): + response = await self.client.role_definitions.get_by_id( + role_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/setup.py b/sdk/authorization/azure-mgmt-authorization/setup.py index 5f47308c560a..4531e46f684d 100644 --- a/sdk/authorization/azure-mgmt-authorization/setup.py +++ b/sdk/authorization/azure-mgmt-authorization/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", )