From 588b35e69251d1077bf3e74f919ce4a2c4d45158 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 4 Mar 2024 20:59:18 +0000 Subject: [PATCH] CodeGen from PR 27789 in Azure/azure-rest-api-specs Merge 12712f27af5e7c70fdc54171cddd78137444d948 into bcecb9990214471ee523e643da76a3a7c4170d2f --- .../azure-mgmt-subscription/_meta.json | 10 +- .../azure/mgmt/subscription/_serialization.py | 119 ++++++++++----- .../mgmt/subscription/_subscription_client.py | 11 +- .../azure/mgmt/subscription/_vendor.py | 11 -- .../azure/mgmt/subscription/_version.py | 2 +- .../subscription/aio/_subscription_client.py | 11 +- .../subscription/aio/operations/__init__.py | 2 + .../aio/operations/_alias_operations.py | 32 ++-- .../operations/_billing_account_operations.py | 10 +- .../aio/operations/_operations.py | 10 +- .../_subscription_operation_operations.py | 115 ++++++++++++++ .../operations/_subscription_operations.py | 41 ++--- .../_subscription_policy_operations.py | 25 ++- .../operations/_subscriptions_operations.py | 20 ++- .../aio/operations/_tenants_operations.py | 10 +- .../mgmt/subscription/models/__init__.py | 2 + .../mgmt/subscription/models/_models_py3.py | 134 +++++++++++------ .../mgmt/subscription/operations/__init__.py | 2 + .../operations/_alias_operations.py | 48 +++--- .../operations/_billing_account_operations.py | 16 +- .../subscription/operations/_operations.py | 12 +- .../_subscription_operation_operations.py | 142 ++++++++++++++++++ .../operations/_subscription_operations.py | 63 ++++---- .../_subscription_policy_operations.py | 31 ++-- .../operations/_subscriptions_operations.py | 32 ++-- .../operations/_tenants_operations.py | 12 +- .../accept_subscription_ownership.py | 3 +- .../generated_samples/delete_alias.py | 3 +- .../get_subscription_operation.py | 39 +++++ 29 files changed, 658 insertions(+), 310 deletions(-) create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operation_operations.py create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operation_operations.py create mode 100644 sdk/subscription/azure-mgmt-subscription/generated_samples/get_subscription_operation.py diff --git a/sdk/subscription/azure-mgmt-subscription/_meta.json b/sdk/subscription/azure-mgmt-subscription/_meta.json index b7ede82ba78d..49d57982ed3e 100644 --- a/sdk/subscription/azure-mgmt-subscription/_meta.json +++ b/sdk/subscription/azure-mgmt-subscription/_meta.json @@ -1,11 +1,11 @@ { - "commit": "89a9bf17524904e7670f0fd2d62ac882ca00d85c", + "commit": "7674d07ef857de83dec51e65e92637290e53afaa", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.2.7", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/subscription/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/subscription/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/subscription/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_serialization.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_serialization.py index 2c170e28dbca..4bae2292227b 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_serialization.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_serialization.py @@ -38,7 +38,22 @@ import re import sys import codecs -from typing import Optional, Union, AnyStr, IO, Mapping +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore @@ -48,12 +63,14 @@ import isodate # type: ignore -from typing import Dict, Any, cast - from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + class RawDeserializer: @@ -277,8 +294,8 @@ class Model(object): _attribute_map: Dict[str, Dict[str, Any]] = {} _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + self.additional_properties: Dict[str, Any] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -287,25 +304,25 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: cls._xml_map # type: ignore except AttributeError: @@ -322,7 +339,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=False, **kwargs): + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: """Return the JSON that would be sent to azure from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -336,8 +353,13 @@ def serialize(self, keep_readonly=False, **kwargs): serializer = Serializer(self._infer_class_models()) return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -384,7 +406,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -396,7 +418,12 @@ def deserialize(cls, data, content_type=None): return deserializer(cls.__name__, data, content_type=content_type) @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -409,8 +436,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -518,7 +545,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -534,7 +561,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -602,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -626,8 +653,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore - unflattened = {k: new_attr} - new_attr = unflattened + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized @@ -636,8 +662,9 @@ 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)) @@ -656,8 +683,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -715,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -723,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -777,6 +804,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -863,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -875,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -922,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -1161,7 +1199,8 @@ def rest_key_extractor(attr, attr_desc, data): working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1242,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1266,7 +1305,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1332,7 +1371,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1352,7 +1391,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1471,7 +1510,7 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ if target is None: return None, None @@ -1486,7 +1525,7 @@ def _classify_target(self, target, data): target = target._classify(data, self.dependencies) except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1496,7 +1535,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py index 469be1f14747..19c0982fd146 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py @@ -19,6 +19,7 @@ AliasOperations, BillingAccountOperations, Operations, + SubscriptionOperationOperations, SubscriptionOperations, SubscriptionPolicyOperations, SubscriptionsOperations, @@ -39,6 +40,9 @@ class SubscriptionClient: # pylint: disable=client-accepts-api-version-keyword, :vartype tenants: azure.mgmt.subscription.operations.TenantsOperations :ivar subscription: SubscriptionOperations operations :vartype subscription: azure.mgmt.subscription.operations.SubscriptionOperations + :ivar subscription_operation: SubscriptionOperationOperations operations + :vartype subscription_operation: + azure.mgmt.subscription.operations.SubscriptionOperationOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.subscription.operations.Operations :ivar alias: AliasOperations operations @@ -59,7 +63,7 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -68,6 +72,9 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_operation = SubscriptionOperationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations(self._client, self._config, self._serialize, self._deserialize) self.subscription_policy = SubscriptionPolicyOperations( @@ -104,5 +111,5 @@ def __enter__(self) -> "SubscriptionClient": self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py index 9aad73fc743e..0dafe0e287ff 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py @@ -14,14 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - formatted_components = template.split("/") - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py index e46fe87dc038..e5754a47ce68 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.2.0b1" +VERSION = "1.0.0b1" diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py index 94baea0fdc2d..2739b30ae2fe 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py @@ -19,6 +19,7 @@ AliasOperations, BillingAccountOperations, Operations, + SubscriptionOperationOperations, SubscriptionOperations, SubscriptionPolicyOperations, SubscriptionsOperations, @@ -39,6 +40,9 @@ class SubscriptionClient: # pylint: disable=client-accepts-api-version-keyword, :vartype tenants: azure.mgmt.subscription.aio.operations.TenantsOperations :ivar subscription: SubscriptionOperations operations :vartype subscription: azure.mgmt.subscription.aio.operations.SubscriptionOperations + :ivar subscription_operation: SubscriptionOperationOperations operations + :vartype subscription_operation: + azure.mgmt.subscription.aio.operations.SubscriptionOperationOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.subscription.aio.operations.Operations :ivar alias: AliasOperations operations @@ -60,7 +64,7 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -69,6 +73,9 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_operation = SubscriptionOperationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations(self._client, self._config, self._serialize, self._deserialize) self.subscription_policy = SubscriptionPolicyOperations( @@ -105,5 +112,5 @@ async def __aenter__(self) -> "SubscriptionClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py index 532abd5a6165..683d1a2a1f59 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py @@ -9,6 +9,7 @@ from ._subscriptions_operations import SubscriptionsOperations from ._tenants_operations import TenantsOperations from ._subscription_operations import SubscriptionOperations +from ._subscription_operation_operations import SubscriptionOperationOperations from ._operations import Operations from ._alias_operations import AliasOperations from ._subscription_policy_operations import SubscriptionPolicyOperations @@ -22,6 +23,7 @@ "SubscriptionsOperations", "TenantsOperations", "SubscriptionOperations", + "SubscriptionOperationOperations", "Operations", "AliasOperations", "SubscriptionPolicyOperations", diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py index 465d1a545db9..95a568067f27 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,14 +72,14 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SubscriptionAliasResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "PutAliasRequest") @@ -101,8 +97,9 @@ async def _create_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -195,7 +192,7 @@ async def begin_create( is not the same as subscription name and this doesn’t have any other lifecycle need beyond the request for subscription creation. Required. :type alias_name: str - :param body: Is either a model type or a IO type. Required. + :param body: Is either a PutAliasRequest type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.PutAliasRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -217,7 +214,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SubscriptionAliasResponse] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -283,7 +280,7 @@ async def get(self, alias_name: str, **kwargs: Any) -> _models.SubscriptionAlias _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.SubscriptionAliasResponse] = kwargs.pop("cls", None) request = build_get_request( @@ -296,8 +293,9 @@ async def get(self, alias_name: str, **kwargs: Any) -> _models.SubscriptionAlias request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -340,7 +338,7 @@ async def delete(self, alias_name: str, **kwargs: Any) -> None: # pylint: disab _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -353,8 +351,9 @@ async def delete(self, alias_name: str, **kwargs: Any) -> None: # pylint: disab request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,7 +388,7 @@ async def list(self, **kwargs: Any) -> _models.SubscriptionAliasListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.SubscriptionAliasListResult] = kwargs.pop("cls", None) request = build_list_request( @@ -401,8 +400,9 @@ async def list(self, **kwargs: Any) -> _models.SubscriptionAliasListResult: request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py index 6aaf16c9eeb2..404ad0e5f1a3 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._billing_account_operations import build_get_policy_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +72,7 @@ async def get_policy(self, billing_account_id: str, **kwargs: Any) -> _models.Bi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.BillingAccountPoliciesResponse] = kwargs.pop("cls", None) request = build_get_policy_request( @@ -90,8 +85,9 @@ async def get_policy(self, billing_account_id: str, **kwargs: Any) -> _models.Bi request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py index 2c830b8f332e..94906fc026a7 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -29,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +63,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -108,8 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operation_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operation_operations.py new file mode 100644 index 000000000000..f8a09af8307d --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operation_operations.py @@ -0,0 +1,115 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._subscription_operation_operations import build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SubscriptionOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`subscription_operation` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, operation_id: str, **kwargs: Any) -> Optional[_models.SubscriptionCreationResult]: + """Get the status of the pending Microsoft.Subscription API operations. + + :param operation_id: The operation ID, which can be found from the Location field in the + generate recommendation response header. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionCreationResult or None or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.SubscriptionCreationResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + cls: ClsType[Optional[_models.SubscriptionCreationResult]] = kwargs.pop("cls", None) + + request = build_get_request( + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("SubscriptionCreationResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {"url": "/providers/Microsoft.Subscription/subscriptionOperations/{operationId}"} diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py index b286154abb73..0eca062e2462 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -36,10 +36,6 @@ build_rename_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,7 +81,7 @@ async def cancel(self, subscription_id: str, **kwargs: Any) -> _models.CanceledS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.CanceledSubscriptionId] = kwargs.pop("cls", None) request = build_cancel_request( @@ -98,8 +94,9 @@ async def cancel(self, subscription_id: str, **kwargs: Any) -> _models.CanceledS request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,7 +166,7 @@ async def rename( :param subscription_id: Subscription Id. Required. :type subscription_id: str - :param body: Subscription Name. Is either a model type or a IO type. Required. + :param body: Subscription Name. Is either a SubscriptionName type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.SubscriptionName or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -190,14 +187,14 @@ async def rename( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RenamedSubscriptionId] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "SubscriptionName") @@ -215,8 +212,9 @@ async def rename( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,7 +255,7 @@ async def enable(self, subscription_id: str, **kwargs: Any) -> _models.EnabledSu _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.EnabledSubscriptionId] = kwargs.pop("cls", None) request = build_enable_request( @@ -270,8 +268,9 @@ async def enable(self, subscription_id: str, **kwargs: Any) -> _models.EnabledSu request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -304,14 +303,14 @@ async def _accept_ownership_initial( # pylint: disable=inconsistent-return-stat _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "AcceptOwnershipRequest") @@ -329,8 +328,9 @@ async def _accept_ownership_initial( # pylint: disable=inconsistent-return-stat request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -416,7 +416,7 @@ async def begin_accept_ownership( :param subscription_id: Subscription Id. Required. :type subscription_id: str - :param body: Is either a model type or a IO type. Required. + :param body: Is either a AcceptOwnershipRequest type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.AcceptOwnershipRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -436,7 +436,7 @@ async def begin_accept_ownership( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -502,7 +502,7 @@ async def accept_ownership_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.AcceptOwnershipStatusResponse] = kwargs.pop("cls", None) request = build_accept_ownership_status_request( @@ -515,8 +515,9 @@ async def accept_ownership_status( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py index 40456472d270..482b34a3bd89 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -34,10 +34,6 @@ build_list_policy_for_tenant_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -101,7 +97,7 @@ async def add_update_policy_for_tenant( ) -> _models.GetTenantPolicyResponse: """Create or Update Subscription tenant policy for user's tenant. - :param body: Is either a model type or a IO type. Required. + :param body: Is either a PutTenantPolicyRequestProperties type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.PutTenantPolicyRequestProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -122,14 +118,14 @@ async def add_update_policy_for_tenant( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GetTenantPolicyResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "PutTenantPolicyRequestProperties") @@ -146,8 +142,9 @@ async def add_update_policy_for_tenant( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -186,7 +183,7 @@ async def get_policy_for_tenant(self, **kwargs: Any) -> _models.GetTenantPolicyR _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.GetTenantPolicyResponse] = kwargs.pop("cls", None) request = build_get_policy_for_tenant_request( @@ -198,8 +195,9 @@ async def get_policy_for_tenant(self, **kwargs: Any) -> _models.GetTenantPolicyR request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -232,7 +230,7 @@ def list_policy_for_tenant(self, **kwargs: Any) -> AsyncIterable["_models.GetTen _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.GetTenantPolicyListResponse] = kwargs.pop("cls", None) error_map = { @@ -272,8 +270,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py index 4ccb0b19749a..075156ccccc1 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._subscriptions_operations import build_get_request, build_list_locations_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +69,7 @@ def list_locations(self, subscription_id: str, **kwargs: Any) -> AsyncIterable[" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.LocationListResult] = kwargs.pop("cls", None) error_map = { @@ -115,8 +110,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,7 +148,7 @@ async def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.Subscription] = kwargs.pop("cls", None) request = build_get_request( @@ -165,8 +161,9 @@ async def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,7 +193,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Subscription"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.SubscriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -236,8 +233,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py index 0c71ef538b84..489763ff3b7c 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -29,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._tenants_operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +64,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.TenantIdDescription"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.TenantListResult] = kwargs.pop("cls", None) error_map = { @@ -109,8 +104,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py index aacbb44efeb7..c6989eee9235 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py @@ -32,6 +32,7 @@ from ._models_py3 import SubscriptionAliasListResult from ._models_py3 import SubscriptionAliasResponse from ._models_py3 import SubscriptionAliasResponseProperties +from ._models_py3 import SubscriptionCreationResult from ._models_py3 import SubscriptionListResult from ._models_py3 import SubscriptionName from ._models_py3 import SubscriptionPolicies @@ -78,6 +79,7 @@ "SubscriptionAliasListResult", "SubscriptionAliasResponse", "SubscriptionAliasResponseProperties", + "SubscriptionCreationResult", "SubscriptionListResult", "SubscriptionName", "SubscriptionPolicies", diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py index b5851f7b2986..84ac4076143a 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization @@ -28,7 +28,9 @@ class AcceptOwnershipRequest(_serialization.Model): "properties": {"key": "properties", "type": "AcceptOwnershipRequestProperties"}, } - def __init__(self, *, properties: Optional["_models.AcceptOwnershipRequestProperties"] = None, **kwargs): + def __init__( + self, *, properties: Optional["_models.AcceptOwnershipRequestProperties"] = None, **kwargs: Any + ) -> None: """ :keyword properties: Accept subscription ownership request properties. :paramtype properties: ~azure.mgmt.subscription.models.AcceptOwnershipRequestProperties @@ -66,8 +68,8 @@ def __init__( display_name: str, management_group_id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword display_name: The friendly name of the subscription. Required. :paramtype display_name: str @@ -128,8 +130,8 @@ def __init__( subscription_tenant_id: Optional[str] = None, display_name: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword subscription_tenant_id: Tenant Id of the subscription. :paramtype subscription_tenant_id: str @@ -180,7 +182,9 @@ class BillingAccountPoliciesResponse(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, properties: Optional["_models.BillingAccountPoliciesResponseProperties"] = None, **kwargs): + def __init__( + self, *, properties: Optional["_models.BillingAccountPoliciesResponseProperties"] = None, **kwargs: Any + ) -> None: """ :keyword properties: Billing account policies response properties. :paramtype properties: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponseProperties @@ -212,8 +216,8 @@ def __init__( *, service_tenants: Optional[List["_models.ServiceTenantResponse"]] = None, allow_transfers: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword service_tenants: Service tenant for the billing account. :paramtype service_tenants: list[~azure.mgmt.subscription.models.ServiceTenantResponse] @@ -242,7 +246,7 @@ class CanceledSubscriptionId(_serialization.Model): "subscription_id": {"key": "subscriptionId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.subscription_id = None @@ -265,7 +269,7 @@ class EnabledSubscriptionId(_serialization.Model): "subscription_id": {"key": "subscriptionId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.subscription_id = None @@ -285,7 +289,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -298,7 +302,8 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, class ErrorResponseBody(_serialization.Model): - """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + """Error response indicates that the service is not able to process the incoming request. The + reason is provided in the error message. :ivar error: The details of the error. :vartype error: ~azure.mgmt.subscription.models.ErrorResponse @@ -320,8 +325,8 @@ def __init__( error: Optional["_models.ErrorResponse"] = None, code: Optional[str] = None, message: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword error: The details of the error. :paramtype error: ~azure.mgmt.subscription.models.ErrorResponse @@ -357,7 +362,7 @@ class GetTenantPolicyListResponse(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.value = None @@ -396,7 +401,7 @@ class GetTenantPolicyResponse(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, properties: Optional["_models.TenantPolicy"] = None, **kwargs): + def __init__(self, *, properties: Optional["_models.TenantPolicy"] = None, **kwargs: Any) -> None: """ :keyword properties: Tenant policy properties. :paramtype properties: ~azure.mgmt.subscription.models.TenantPolicy @@ -447,7 +452,7 @@ class Location(_serialization.Model): "longitude": {"key": "longitude", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -469,7 +474,7 @@ class LocationListResult(_serialization.Model): "value": {"key": "value", "type": "[Location]"}, } - def __init__(self, *, value: Optional[List["_models.Location"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.Location"]] = None, **kwargs: Any) -> None: """ :keyword value: An array of locations. :paramtype value: list[~azure.mgmt.subscription.models.Location] @@ -501,8 +506,8 @@ def __init__( name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str @@ -544,8 +549,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Service provider: Microsoft.Subscription. :paramtype provider: str @@ -564,7 +569,8 @@ def __init__( class OperationListResult(_serialization.Model): - """Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. + """Result of the request to list operations. It contains a list of operations and a URL link to + get the next set of results. :ivar value: List of operations. :vartype value: list[~azure.mgmt.subscription.models.Operation] @@ -577,7 +583,9 @@ class OperationListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: List of operations. :paramtype value: list[~azure.mgmt.subscription.models.Operation] @@ -600,7 +608,7 @@ class PutAliasRequest(_serialization.Model): "properties": {"key": "properties", "type": "PutAliasRequestProperties"}, } - def __init__(self, *, properties: Optional["_models.PutAliasRequestProperties"] = None, **kwargs): + def __init__(self, *, properties: Optional["_models.PutAliasRequestProperties"] = None, **kwargs: Any) -> None: """ :keyword properties: Put alias request properties. :paramtype properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties @@ -636,8 +644,8 @@ def __init__( subscription_tenant_id: Optional[str] = None, subscription_owner_id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword management_group_id: Management group Id for the subscription. :paramtype management_group_id: str @@ -697,8 +705,8 @@ def __init__( subscription_id: Optional[str] = None, reseller_id: Optional[str] = None, additional_properties: Optional["_models.PutAliasRequestAdditionalProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword display_name: The friendly name of the subscription. :paramtype display_name: str @@ -755,8 +763,8 @@ def __init__( block_subscriptions_leaving_tenant: Optional[bool] = None, block_subscriptions_into_tenant: Optional[bool] = None, exempted_principals: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's tenant. @@ -791,7 +799,7 @@ class RenamedSubscriptionId(_serialization.Model): "subscription_id": {"key": "subscriptionId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.subscription_id = None @@ -811,7 +819,7 @@ class ServiceTenantResponse(_serialization.Model): "tenant_name": {"key": "tenantName", "type": "str"}, } - def __init__(self, *, tenant_id: Optional[str] = None, tenant_name: Optional[str] = None, **kwargs): + def __init__(self, *, tenant_id: Optional[str] = None, tenant_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword tenant_id: Service tenant id. :paramtype tenant_id: str @@ -875,8 +883,8 @@ def __init__( tags: Optional[Dict[str, str]] = None, subscription_policies: Optional["_models.SubscriptionPolicies"] = None, authorization_source: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Tags for the subscription. :paramtype tags: dict[str, str] @@ -919,7 +927,7 @@ class SubscriptionAliasListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.value = None @@ -958,7 +966,9 @@ class SubscriptionAliasResponse(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, properties: Optional["_models.SubscriptionAliasResponseProperties"] = None, **kwargs): + def __init__( + self, *, properties: Optional["_models.SubscriptionAliasResponseProperties"] = None, **kwargs: Any + ) -> None: """ :keyword properties: Subscription Alias response properties. :paramtype properties: ~azure.mgmt.subscription.models.SubscriptionAliasResponseProperties @@ -1043,8 +1053,8 @@ def __init__( management_group_id: Optional[str] = None, created_time: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword display_name: The display name of the subscription. :paramtype display_name: str @@ -1087,6 +1097,28 @@ def __init__( self.tags = tags +class SubscriptionCreationResult(_serialization.Model): + """The created subscription object. + + :ivar subscription_link: The link to the new subscription. Use this link to check the status of + subscription creation operation. + :vartype subscription_link: str + """ + + _attribute_map = { + "subscription_link": {"key": "subscriptionLink", "type": "str"}, + } + + def __init__(self, *, subscription_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword subscription_link: The link to the new subscription. Use this link to check the status + of subscription creation operation. + :paramtype subscription_link: str + """ + super().__init__(**kwargs) + self.subscription_link = subscription_link + + class SubscriptionListResult(_serialization.Model): """Subscription list operation response. @@ -1102,8 +1134,8 @@ class SubscriptionListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.Subscription"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.Subscription"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: An array of subscriptions. :paramtype value: list[~azure.mgmt.subscription.models.Subscription] @@ -1126,7 +1158,7 @@ class SubscriptionName(_serialization.Model): "subscription_name": {"key": "subscriptionName", "type": "str"}, } - def __init__(self, *, subscription_name: Optional[str] = None, **kwargs): + def __init__(self, *, subscription_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword subscription_name: New subscription name. :paramtype subscription_name: str @@ -1163,7 +1195,7 @@ class SubscriptionPolicies(_serialization.Model): "spending_limit": {"key": "spendingLimit", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.location_placement_id = None @@ -1208,8 +1240,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -1286,7 +1318,7 @@ class TenantIdDescription(_serialization.Model): "tenant_type": {"key": "tenantType", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -1320,7 +1352,9 @@ class TenantListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, next_link: str, value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs): + def __init__( + self, *, next_link: str, value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs: Any + ) -> None: """ :keyword value: An array of tenants. :paramtype value: list[~azure.mgmt.subscription.models.TenantIdDescription] @@ -1366,8 +1400,8 @@ def __init__( block_subscriptions_leaving_tenant: Optional[bool] = None, block_subscriptions_into_tenant: Optional[bool] = None, exempted_principals: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's tenant. diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py index 532abd5a6165..683d1a2a1f59 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py @@ -9,6 +9,7 @@ from ._subscriptions_operations import SubscriptionsOperations from ._tenants_operations import TenantsOperations from ._subscription_operations import SubscriptionOperations +from ._subscription_operation_operations import SubscriptionOperationOperations from ._operations import Operations from ._alias_operations import AliasOperations from ._subscription_policy_operations import SubscriptionPolicyOperations @@ -22,6 +23,7 @@ "SubscriptionsOperations", "TenantsOperations", "SubscriptionOperations", + "SubscriptionOperationOperations", "Operations", "AliasOperations", "SubscriptionPolicyOperations", diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py index 07dc46d3d050..a40f610420ad 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_create_request(alias_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -55,7 +51,7 @@ def build_create_request(alias_name: str, **kwargs: Any) -> HttpRequest: "aliasName": _SERIALIZER.url("alias_name", alias_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") @@ -72,7 +68,7 @@ def build_get_request(alias_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +77,7 @@ def build_get_request(alias_name: str, **kwargs: Any) -> HttpRequest: "aliasName": _SERIALIZER.url("alias_name", alias_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") @@ -96,7 +92,7 @@ def build_delete_request(alias_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +101,7 @@ def build_delete_request(alias_name: str, **kwargs: Any) -> HttpRequest: "aliasName": _SERIALIZER.url("alias_name", alias_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") @@ -120,7 +116,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,14 +164,14 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SubscriptionAliasResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "PutAliasRequest") @@ -193,8 +189,9 @@ def _create_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,7 +284,7 @@ def begin_create( is not the same as subscription name and this doesn’t have any other lifecycle need beyond the request for subscription creation. Required. :type alias_name: str - :param body: Is either a model type or a IO type. Required. + :param body: Is either a PutAliasRequest type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.PutAliasRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -309,7 +306,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SubscriptionAliasResponse] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -375,7 +372,7 @@ def get(self, alias_name: str, **kwargs: Any) -> _models.SubscriptionAliasRespon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.SubscriptionAliasResponse] = kwargs.pop("cls", None) request = build_get_request( @@ -388,8 +385,9 @@ def get(self, alias_name: str, **kwargs: Any) -> _models.SubscriptionAliasRespon request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -432,7 +430,7 @@ def delete(self, alias_name: str, **kwargs: Any) -> None: # pylint: disable=inc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -445,8 +443,9 @@ def delete(self, alias_name: str, **kwargs: Any) -> None: # pylint: disable=inc request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -481,7 +480,7 @@ def list(self, **kwargs: Any) -> _models.SubscriptionAliasListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.SubscriptionAliasListResult] = kwargs.pop("cls", None) request = build_list_request( @@ -493,8 +492,9 @@ def list(self, **kwargs: Any) -> _models.SubscriptionAliasListResult: request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py index c72c6ffb0353..f532f51262f8 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_policy_request(billing_account_id: str, **kwargs: Any) -> HttpRequ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +50,7 @@ def build_get_policy_request(billing_account_id: str, **kwargs: Any) -> HttpRequ "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_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") @@ -107,7 +102,7 @@ def get_policy(self, billing_account_id: str, **kwargs: Any) -> _models.BillingA _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.BillingAccountPoliciesResponse] = kwargs.pop("cls", None) request = build_get_policy_request( @@ -120,8 +115,9 @@ def get_policy(self, billing_account_id: str, **kwargs: Any) -> _models.BillingA request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py index fb51fee6f83f..a27a8934b117 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -29,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +39,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +85,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -130,8 +125,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operation_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operation_operations.py new file mode 100644 index 000000000000..3002936a1fb1 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operation_operations.py @@ -0,0 +1,142 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(operation_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Subscription/subscriptionOperations/{operationId}") + path_format_arguments = { + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SubscriptionOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`subscription_operation` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, operation_id: str, **kwargs: Any) -> Optional[_models.SubscriptionCreationResult]: + """Get the status of the pending Microsoft.Subscription API operations. + + :param operation_id: The operation ID, which can be found from the Location field in the + generate recommendation response header. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionCreationResult or None or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.SubscriptionCreationResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + cls: ClsType[Optional[_models.SubscriptionCreationResult]] = kwargs.pop("cls", None) + + request = build_get_request( + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("SubscriptionCreationResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {"url": "/providers/Microsoft.Subscription/subscriptionOperations/{operationId}"} diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py index bbea1fe2c189..d40e4e425148 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_cancel_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +50,7 @@ def build_cancel_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") @@ -69,7 +65,7 @@ def build_rename_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -79,7 +75,7 @@ def build_rename_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") @@ -96,7 +92,7 @@ def build_enable_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +101,7 @@ def build_enable_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") @@ -120,7 +116,7 @@ def build_accept_ownership_request(subscription_id: str, **kwargs: Any) -> HttpR _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +128,7 @@ def build_accept_ownership_request(subscription_id: str, **kwargs: Any) -> HttpR "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") @@ -149,7 +145,7 @@ def build_accept_ownership_status_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +156,7 @@ def build_accept_ownership_status_request(subscription_id: str, **kwargs: Any) - "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") @@ -212,7 +208,7 @@ def cancel(self, subscription_id: str, **kwargs: Any) -> _models.CanceledSubscri _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.CanceledSubscriptionId] = kwargs.pop("cls", None) request = build_cancel_request( @@ -225,8 +221,9 @@ def cancel(self, subscription_id: str, **kwargs: Any) -> _models.CanceledSubscri request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -296,7 +293,7 @@ def rename( :param subscription_id: Subscription Id. Required. :type subscription_id: str - :param body: Subscription Name. Is either a model type or a IO type. Required. + :param body: Subscription Name. Is either a SubscriptionName type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.SubscriptionName or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -317,14 +314,14 @@ def rename( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RenamedSubscriptionId] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "SubscriptionName") @@ -342,8 +339,9 @@ def rename( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,7 +382,7 @@ def enable(self, subscription_id: str, **kwargs: Any) -> _models.EnabledSubscrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.EnabledSubscriptionId] = kwargs.pop("cls", None) request = build_enable_request( @@ -397,8 +395,9 @@ def enable(self, subscription_id: str, **kwargs: Any) -> _models.EnabledSubscrip request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -431,14 +430,14 @@ def _accept_ownership_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "AcceptOwnershipRequest") @@ -456,8 +455,9 @@ def _accept_ownership_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -543,7 +543,7 @@ def begin_accept_ownership( :param subscription_id: Subscription Id. Required. :type subscription_id: str - :param body: Is either a model type or a IO type. Required. + :param body: Is either a AcceptOwnershipRequest type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.AcceptOwnershipRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -563,7 +563,7 @@ def begin_accept_ownership( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -627,7 +627,7 @@ def accept_ownership_status(self, subscription_id: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.AcceptOwnershipStatusResponse] = kwargs.pop("cls", None) request = build_accept_ownership_status_request( @@ -640,8 +640,9 @@ def accept_ownership_status(self, subscription_id: str, **kwargs: Any) -> _model request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py index 8e7ce54425dc..94e82e514413 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +40,7 @@ def build_add_update_policy_for_tenant_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -66,7 +62,7 @@ def build_get_policy_for_tenant_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +81,7 @@ def build_list_policy_for_tenant_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +155,7 @@ def add_update_policy_for_tenant( ) -> _models.GetTenantPolicyResponse: """Create or Update Subscription tenant policy for user's tenant. - :param body: Is either a model type or a IO type. Required. + :param body: Is either a PutTenantPolicyRequestProperties type or a IO type. Required. :type body: ~azure.mgmt.subscription.models.PutTenantPolicyRequestProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -180,14 +176,14 @@ def add_update_policy_for_tenant( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GetTenantPolicyResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "PutTenantPolicyRequestProperties") @@ -204,8 +200,9 @@ def add_update_policy_for_tenant( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,7 +241,7 @@ def get_policy_for_tenant(self, **kwargs: Any) -> _models.GetTenantPolicyRespons _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.GetTenantPolicyResponse] = kwargs.pop("cls", None) request = build_get_policy_for_tenant_request( @@ -256,8 +253,9 @@ def get_policy_for_tenant(self, **kwargs: Any) -> _models.GetTenantPolicyRespons request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -289,7 +287,7 @@ def list_policy_for_tenant(self, **kwargs: Any) -> Iterable["_models.GetTenantPo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) cls: ClsType[_models.GetTenantPolicyListResponse] = kwargs.pop("cls", None) error_map = { @@ -329,8 +327,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py index 7157c104c13b..3fdcef632dd4 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -27,12 +26,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +39,7 @@ def build_list_locations_request(subscription_id: str, **kwargs: Any) -> HttpReq _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +48,7 @@ def build_list_locations_request(subscription_id: str, **kwargs: Any) -> HttpReq "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") @@ -68,7 +63,7 @@ def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -77,7 +72,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") @@ -92,7 +87,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +138,7 @@ def list_locations(self, subscription_id: str, **kwargs: Any) -> Iterable["_mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.LocationListResult] = kwargs.pop("cls", None) error_map = { @@ -184,8 +179,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,7 +217,7 @@ def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.Subscription] = kwargs.pop("cls", None) request = build_get_request( @@ -234,8 +230,9 @@ def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -265,7 +262,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Subscription"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.SubscriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -305,8 +302,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py index adc5c6116e4d..70d179c581ff 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -29,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +39,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +85,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.TenantIdDescription"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) cls: ClsType[_models.TenantListResult] = kwargs.pop("cls", None) error_map = { @@ -130,8 +125,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/subscription/azure-mgmt-subscription/generated_samples/accept_subscription_ownership.py b/sdk/subscription/azure-mgmt-subscription/generated_samples/accept_subscription_ownership.py index ac6a68c4df75..d811881717f1 100644 --- a/sdk/subscription/azure-mgmt-subscription/generated_samples/accept_subscription_ownership.py +++ b/sdk/subscription/azure-mgmt-subscription/generated_samples/accept_subscription_ownership.py @@ -28,7 +28,7 @@ def main(): credential=DefaultAzureCredential(), ) - response = client.subscription.begin_accept_ownership( + client.subscription.begin_accept_ownership( subscription_id="291bba3f-e0a5-47bc-a099-3bdcb2a50a05", body={ "properties": { @@ -38,7 +38,6 @@ def main(): } }, ).result() - print(response) # x-ms-original-file: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/acceptSubscriptionOwnership.json diff --git a/sdk/subscription/azure-mgmt-subscription/generated_samples/delete_alias.py b/sdk/subscription/azure-mgmt-subscription/generated_samples/delete_alias.py index d8a6ad618c7c..c611229588c6 100644 --- a/sdk/subscription/azure-mgmt-subscription/generated_samples/delete_alias.py +++ b/sdk/subscription/azure-mgmt-subscription/generated_samples/delete_alias.py @@ -28,10 +28,9 @@ def main(): credential=DefaultAzureCredential(), ) - response = client.alias.delete( + client.alias.delete( alias_name="aliasForNewSub", ) - print(response) # x-ms-original-file: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/deleteAlias.json diff --git a/sdk/subscription/azure-mgmt-subscription/generated_samples/get_subscription_operation.py b/sdk/subscription/azure-mgmt-subscription/generated_samples/get_subscription_operation.py new file mode 100644 index 000000000000..5a3e0cd7f47b --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/generated_samples/get_subscription_operation.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.subscription import SubscriptionClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-subscription +# USAGE + python get_subscription_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SubscriptionClient( + credential=DefaultAzureCredential(), + ) + + response = client.subscription_operation.get( + operation_id="e4b8d068-f574-462a-a76f-6fa0afc613c9", + ) + print(response) + + +# x-ms-original-file: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/getSubscriptionOperation.json +if __name__ == "__main__": + main()