From 16d96f136c8a1f55916c29fb58afc463b823d02d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 25 Sep 2024 12:58:57 +0000 Subject: [PATCH] CodeGen from PR 30711 in Azure/azure-rest-api-specs Merge c00305542861e4c1e255d538c87b8cdea6a40032 into 2cec543b4bf04ccd1971ae69a136cf06878439b2 --- sdk/astro/azure-mgmt-astro/_meta.json | 10 +- .../azure/mgmt/astro/_astro_mgmt_client.py | 31 +- .../azure/mgmt/astro/_configuration.py | 11 +- .../azure/mgmt/astro/_serialization.py | 94 +++-- .../azure/mgmt/astro/_vendor.py | 16 - .../mgmt/astro/aio/_astro_mgmt_client.py | 33 +- .../azure/mgmt/astro/aio/_configuration.py | 11 +- .../mgmt/astro/aio/operations/_operations.py | 37 +- .../operations/_organizations_operations.py | 317 ++++++----------- .../azure/mgmt/astro/models/__init__.py | 4 +- .../astro/models/_astro_mgmt_client_enums.py | 17 +- .../azure/mgmt/astro/models/_models_py3.py | 56 +-- .../mgmt/astro/operations/_operations.py | 39 +-- .../operations/_organizations_operations.py | 329 +++++++----------- .../operations_list_maximum_set_gen.py | 3 +- .../operations_list_minimum_set_gen.py | 40 +++ ...ations_create_or_update_maximum_set_gen.py | 42 +-- .../organizations_delete_maximum_set_gen.py | 7 +- .../organizations_get_maximum_set_gen.py | 7 +- ..._list_by_resource_group_maximum_set_gen.py | 5 +- ..._list_by_resource_group_minimum_set_gen.py | 42 +++ ...ns_list_by_subscription_maximum_set_gen.py | 5 +- ...ns_list_by_subscription_minimum_set_gen.py | 40 +++ .../organizations_update_maximum_set_gen.py | 31 +- .../generated_tests/conftest.py | 35 ++ .../test_astro_mgmt_operations.py | 29 ++ .../test_astro_mgmt_operations_async.py | 30 ++ ...est_astro_mgmt_organizations_operations.py | 177 ++++++++++ ...tro_mgmt_organizations_operations_async.py | 184 ++++++++++ sdk/astro/azure-mgmt-astro/setup.py | 7 +- 30 files changed, 1063 insertions(+), 626 deletions(-) delete mode 100644 sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_vendor.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_samples/operations_list_minimum_set_gen.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_minimum_set_gen.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_tests/conftest.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations_async.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations.py create mode 100644 sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations_async.py diff --git a/sdk/astro/azure-mgmt-astro/_meta.json b/sdk/astro/azure-mgmt-astro/_meta.json index 1cc132dc5b9e..a31771e468f9 100644 --- a/sdk/astro/azure-mgmt-astro/_meta.json +++ b/sdk/astro/azure-mgmt-astro/_meta.json @@ -1,11 +1,11 @@ { - "commit": "8bf9ff0986adb3b37755d8b0a0dfab93906d2eab", + "commit": "0953b2db386273bdd0e1243ebe57df2080cfc10f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/liftrastronomer/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.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/liftrastronomer/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/liftrastronomer/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_astro_mgmt_client.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_astro_mgmt_client.py index 565803581b16..17da7b6b375f 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_astro_mgmt_client.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_astro_mgmt_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import AstroMgmtClientConfiguration @@ -35,7 +38,7 @@ class AstroMgmtClient: # pylint: disable=client-accepts-api-version-keyword :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-08-27". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -50,7 +53,25 @@ def __init__( **kwargs: Any ) -> None: self._config = AstroMgmtClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -59,7 +80,7 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +100,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AstroMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_configuration.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_configuration.py index f8fc317a5096..6f56be37f3ef 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_configuration.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AstroMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AstroMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AstroMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class AstroMgmtClientConfiguration(Configuration): # pylint: disable=too-many-i :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-08-27". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AstroMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-08-01") + api_version: str = kwargs.pop("api_version", "2024-08-27") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-astro/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_serialization.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_serialization.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,7 +663,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +740,7 @@ def query(self, name, data, data_type, **kwargs): :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 + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +749,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -804,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1170,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1371,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1444,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1481,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1578,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1652,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1757,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1808,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1862,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_vendor.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_astro_mgmt_client.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_astro_mgmt_client.py index ae9b15582768..04ea8f4df4ad 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_astro_mgmt_client.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_astro_mgmt_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -35,7 +38,7 @@ class AstroMgmtClient: # pylint: disable=client-accepts-api-version-keyword :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-08-27". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -50,7 +53,25 @@ def __init__( **kwargs: Any ) -> None: self._config = AstroMgmtClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -59,7 +80,9 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,12 +102,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AstroMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_configuration.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_configuration.py index 10f86d3b6693..36c6cba0b22b 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_configuration.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AstroMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AstroMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AstroMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class AstroMgmtClientConfiguration(Configuration): # pylint: disable=too-many-i :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-08-27". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AstroMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-08-01") + api_version: str = kwargs.pop("api_version", "2024-08-27") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-astro/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_operations.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_operations.py index 0f6dbb9d4dad..0baae3dafc32 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_operations.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List the operations for the provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.astro.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -67,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,14 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -97,13 +97,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -113,11 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Astronomer.Astro/operations"} diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_organizations_operations.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_organizations_operations.py index 6a81e38bb2a9..5af88a84c472 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_organizations_operations.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/aio/operations/_organizations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._organizations_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +72,6 @@ def __init__(self, *args, **kwargs) -> None: def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.OrganizationResource"]: """List OrganizationResource resources by subscription ID. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OrganizationResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.astro.models.OrganizationResource] @@ -79,7 +83,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Organiza api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OrganizationResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +94,13 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Organiza def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,13 +112,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OrganizationResourceListResult", pipeline_response) @@ -126,11 +127,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,8 +144,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Astronomer.Astro/organizations"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -154,7 +153,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OrganizationResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.astro.models.OrganizationResource] @@ -166,7 +164,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OrganizationResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,16 +175,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -198,13 +194,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OrganizationResourceListResult", pipeline_response) @@ -214,11 +209,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -231,10 +226,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations" - } - @distributed_trace_async async def get( self, resource_group_name: str, organization_name: str, **kwargs: Any @@ -246,12 +237,11 @@ async def get( :type resource_group_name: str :param organization_name: Name of the Organizations resource. Required. :type organization_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OrganizationResource or the result of cls(response) :rtype: ~azure.mgmt.astro.models.OrganizationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,21 +255,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OrganizationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -289,25 +277,21 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = self._deserialize("OrganizationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, organization_name: str, - resource: Union[_models.OrganizationResource, IO], + resource: Union[_models.OrganizationResource, IO[bytes]], **kwargs: Any - ) -> _models.OrganizationResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -320,7 +304,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OrganizationResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -330,7 +314,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(resource, "OrganizationResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, @@ -338,43 +322,39 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OrganizationResource", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } - @overload async def begin_create_or_update( self, @@ -397,14 +377,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -416,7 +388,7 @@ async def begin_create_or_update( self, resource_group_name: str, organization_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -429,18 +401,10 @@ async def begin_create_or_update( :param organization_name: Name of the Organizations resource. Required. :type organization_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -452,7 +416,7 @@ async def begin_create_or_update( self, resource_group_name: str, organization_name: str, - resource: Union[_models.OrganizationResource, IO], + resource: Union[_models.OrganizationResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OrganizationResource]: """Create a OrganizationResource. @@ -462,20 +426,9 @@ async def begin_create_or_update( :type resource_group_name: str :param organization_name: Name of the Organizations resource. Required. :type organization_name: str - :param resource: Resource create parameters. Is either a OrganizationResource type or a IO - type. Required. - :type resource: ~azure.mgmt.astro.models.OrganizationResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param resource: Resource create parameters. Is either a OrganizationResource type or a + IO[bytes] type. Required. + :type resource: ~azure.mgmt.astro.models.OrganizationResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -502,12 +455,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = self._deserialize("OrganizationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -520,26 +474,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OrganizationResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return AsyncLROPoller[_models.OrganizationResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, organization_name: str, - properties: Union[_models.OrganizationResourceUpdate, IO], + properties: Union[_models.OrganizationResourceUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OrganizationResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -552,7 +504,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OrganizationResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -562,7 +514,7 @@ async def _update_initial( else: _json = self._serialize.body(properties, "OrganizationResourceUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, @@ -570,42 +522,39 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OrganizationResource", pipeline_response) - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -629,14 +578,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -648,7 +589,7 @@ async def begin_update( self, resource_group_name: str, organization_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -661,18 +602,10 @@ async def begin_update( :param organization_name: Name of the Organizations resource. Required. :type organization_name: str :param properties: The resource properties to be updated. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -684,7 +617,7 @@ async def begin_update( self, resource_group_name: str, organization_name: str, - properties: Union[_models.OrganizationResourceUpdate, IO], + properties: Union[_models.OrganizationResourceUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OrganizationResource]: """Update a OrganizationResource. @@ -695,19 +628,8 @@ async def begin_update( :param organization_name: Name of the Organizations resource. Required. :type organization_name: str :param properties: The resource properties to be updated. Is either a - OrganizationResourceUpdate type or a IO type. Required. - :type properties: ~azure.mgmt.astro.models.OrganizationResourceUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + OrganizationResourceUpdate type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.astro.models.OrganizationResourceUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -734,12 +656,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = self._deserialize("OrganizationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -751,22 +674,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OrganizationResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return AsyncLROPoller[_models.OrganizationResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, organization_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -778,43 +699,46 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -827,14 +751,6 @@ async def begin_delete( :type resource_group_name: str :param organization_name: Name of the Organizations resource. Required. :type organization_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -848,7 +764,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, organization_name=organization_name, api_version=api_version, @@ -857,11 +773,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -872,14 +789,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/__init__.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/__init__.py index 1b0d393b5823..f61c1be40fc1 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/__init__.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/__init__.py @@ -35,9 +35,9 @@ from ._astro_mgmt_client_enums import ManagedServiceIdentityType from ._astro_mgmt_client_enums import MarketplaceSubscriptionStatus from ._astro_mgmt_client_enums import Origin +from ._astro_mgmt_client_enums import RenewalMode from ._astro_mgmt_client_enums import ResourceProvisioningState from ._astro_mgmt_client_enums import SingleSignOnStates -from ._astro_mgmt_client_enums import Versions from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -71,9 +71,9 @@ "ManagedServiceIdentityType", "MarketplaceSubscriptionStatus", "Origin", + "RenewalMode", "ResourceProvisioningState", "SingleSignOnStates", - "Versions", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_astro_mgmt_client_enums.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_astro_mgmt_client_enums.py index 0be2e6dcdbcf..1b1a12793b5d 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_astro_mgmt_client_enums.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_astro_mgmt_client_enums.py @@ -59,6 +59,15 @@ class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_SYSTEM = "user,system" +class RenewalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Subscription renewal mode.""" + + AUTO = "Auto" + """Automatic renewal""" + MANUAL = "Manual" + """Manual renewal""" + + class ResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of a resource type.""" @@ -79,11 +88,3 @@ class SingleSignOnStates(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of the SSO resource when it is enabled""" DISABLE = "Disable" """State of the SSO resource when it is disabled""" - - -class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Supported API versions for the Astronomer.Astro resource provider.""" - - V1_PREVIEW = "2023-08-01" - """Dependent on Azure.ResourceManager.Versions.v1_0_Preview_1, LiftrBase.Versions.v1_preview, - #: LiftrBase.Data.Versions.v1_preview""" diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_models_py3.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_models_py3.py index 1cb3f9e9f83f..6ef46a1fc5c8 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_models_py3.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/models/_models_py3.py @@ -114,7 +114,7 @@ class LiftrBaseDataOrganizationProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar marketplace: Marketplace details of the resource. Required. :vartype marketplace: ~azure.mgmt.astro.models.LiftrBaseMarketplaceDetails @@ -168,10 +168,10 @@ def __init__( self.partner_organization_properties = partner_organization_properties -class LiftrBaseDataPartnerOrganizationProperties(_serialization.Model): +class LiftrBaseDataPartnerOrganizationProperties(_serialization.Model): # pylint: disable=name-too-long """Properties specific to Partner's organization. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar organization_id: Organization Id in partner's system. :vartype organization_id: str @@ -233,7 +233,7 @@ def __init__( self.single_sign_on_properties = single_sign_on_properties -class LiftrBaseDataPartnerOrganizationPropertiesUpdate(_serialization.Model): +class LiftrBaseDataPartnerOrganizationPropertiesUpdate(_serialization.Model): # pylint: disable=name-too-long """Properties specific to Partner's organization. :ivar organization_id: Organization Id in partner's system. @@ -294,10 +294,9 @@ def __init__( class LiftrBaseMarketplaceDetails(_serialization.Model): """Marketplace details for an organization. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar subscription_id: Azure subscription id for the the marketplace offer is purchased from. - Required. :vartype subscription_id: str :ivar subscription_status: Marketplace subscription status. Known values are: "PendingFulfillmentStart", "Subscribed", "Suspended", and "Unsubscribed". @@ -307,7 +306,6 @@ class LiftrBaseMarketplaceDetails(_serialization.Model): """ _validation = { - "subscription_id": {"required": True}, "offer_details": {"required": True}, } @@ -320,14 +318,14 @@ class LiftrBaseMarketplaceDetails(_serialization.Model): def __init__( self, *, - subscription_id: str, offer_details: "_models.LiftrBaseOfferDetails", + subscription_id: Optional[str] = None, subscription_status: Optional[Union[str, "_models.MarketplaceSubscriptionStatus"]] = None, **kwargs: Any ) -> None: """ :keyword subscription_id: Azure subscription id for the the marketplace offer is purchased - from. Required. + from. :paramtype subscription_id: str :keyword subscription_status: Marketplace subscription status. Known values are: "PendingFulfillmentStart", "Subscribed", "Suspended", and "Unsubscribed". @@ -345,7 +343,9 @@ def __init__( class LiftrBaseOfferDetails(_serialization.Model): """Offer details for the marketplace that is selected by the user. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. :ivar publisher_id: Publisher Id for the marketplace offer. Required. :vartype publisher_id: str @@ -359,12 +359,17 @@ class LiftrBaseOfferDetails(_serialization.Model): :vartype term_unit: str :ivar term_id: Plan Display Name for the marketplace offer. :vartype term_id: str + :ivar renewal_mode: Subscription renewal mode. Known values are: "Auto" and "Manual". + :vartype renewal_mode: str or ~azure.mgmt.astro.models.RenewalMode + :ivar end_date: Current subscription end date and time. + :vartype end_date: ~datetime.datetime """ _validation = { "publisher_id": {"required": True}, "offer_id": {"required": True}, "plan_id": {"required": True}, + "end_date": {"readonly": True}, } _attribute_map = { @@ -374,6 +379,8 @@ class LiftrBaseOfferDetails(_serialization.Model): "plan_name": {"key": "planName", "type": "str"}, "term_unit": {"key": "termUnit", "type": "str"}, "term_id": {"key": "termId", "type": "str"}, + "renewal_mode": {"key": "renewalMode", "type": "str"}, + "end_date": {"key": "endDate", "type": "iso-8601"}, } def __init__( @@ -385,6 +392,7 @@ def __init__( plan_name: Optional[str] = None, term_unit: Optional[str] = None, term_id: Optional[str] = None, + renewal_mode: Optional[Union[str, "_models.RenewalMode"]] = None, **kwargs: Any ) -> None: """ @@ -400,6 +408,8 @@ def __init__( :paramtype term_unit: str :keyword term_id: Plan Display Name for the marketplace offer. :paramtype term_id: str + :keyword renewal_mode: Subscription renewal mode. Known values are: "Auto" and "Manual". + :paramtype renewal_mode: str or ~azure.mgmt.astro.models.RenewalMode """ super().__init__(**kwargs) self.publisher_id = publisher_id @@ -408,6 +418,8 @@ def __init__( self.plan_name = plan_name self.term_unit = term_unit self.term_id = term_id + self.renewal_mode = renewal_mode + self.end_date = None class LiftrBaseSingleSignOnProperties(_serialization.Model): @@ -474,7 +486,7 @@ def __init__( class LiftrBaseUserDetails(_serialization.Model): """User details for an organization. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar first_name: First name of the user. Required. :vartype first_name: str @@ -594,7 +606,7 @@ class ManagedServiceIdentity(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -608,7 +620,7 @@ class ManagedServiceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.astro.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.astro.models.UserAssignedIdentity] """ @@ -640,7 +652,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.astro.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.astro.models.UserAssignedIdentity] """ @@ -778,7 +790,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -819,10 +831,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -872,10 +884,10 @@ class OrganizationResource(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -941,7 +953,7 @@ def __init__( class OrganizationResourceListResult(_serialization.Model): """The response of a OrganizationResource list operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar value: The OrganizationResource items on this page. Required. :vartype value: list[~azure.mgmt.astro.models.OrganizationResource] @@ -979,7 +991,7 @@ class OrganizationResourceUpdate(_serialization.Model): :vartype identity: ~azure.mgmt.astro.models.ManagedServiceIdentity :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar properties: The updatable properties of the OrganizationResource. + :ivar properties: The resource-specific properties for this resource. :vartype properties: ~azure.mgmt.astro.models.OrganizationResourceUpdateProperties """ @@ -1002,7 +1014,7 @@ def __init__( :paramtype identity: ~azure.mgmt.astro.models.ManagedServiceIdentity :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword properties: The updatable properties of the OrganizationResource. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.astro.models.OrganizationResourceUpdateProperties """ super().__init__(**kwargs) diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_operations.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_operations.py index 65f70e51c254..83f1469bbb69 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_operations.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-27")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +81,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List the operations for the provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.astro.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -89,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,14 +102,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +119,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -135,11 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Astronomer.Astro/operations"} diff --git a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_organizations_operations.py b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_organizations_operations.py index 505051c3ad0f..68f3cace1f39 100644 --- a/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_organizations_operations.py +++ b/sdk/astro/azure-mgmt-astro/azure/mgmt/astro/operations/_organizations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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", "2023-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-27")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +72,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-27")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +104,7 @@ def build_get_request( _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", "2023-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-27")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -139,7 +144,7 @@ def build_create_or_update_request( _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", "2023-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-27")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -182,7 +187,7 @@ def build_update_request( _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", "2023-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-27")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -225,7 +230,7 @@ def build_delete_request( _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", "2023-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-27")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -282,7 +287,6 @@ def __init__(self, *args, **kwargs): def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.OrganizationResource"]: """List OrganizationResource resources by subscription ID. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OrganizationResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.astro.models.OrganizationResource] @@ -294,7 +298,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.OrganizationR api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OrganizationResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,15 +309,13 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.OrganizationR def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -325,13 +327,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OrganizationResourceListResult", pipeline_response) @@ -341,11 +342,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,8 +359,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Astronomer.Astro/organizations"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -369,7 +368,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OrganizationResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.astro.models.OrganizationResource] @@ -381,7 +379,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OrganizationResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,16 +390,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -413,13 +409,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OrganizationResourceListResult", pipeline_response) @@ -429,11 +424,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,10 +441,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations" - } - @distributed_trace def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> _models.OrganizationResource: """Get a OrganizationResource. @@ -459,12 +450,11 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - :type resource_group_name: str :param organization_name: Name of the Organizations resource. Required. :type organization_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OrganizationResource or the result of cls(response) :rtype: ~azure.mgmt.astro.models.OrganizationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,21 +468,19 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OrganizationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -502,25 +490,21 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = self._deserialize("OrganizationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, organization_name: str, - resource: Union[_models.OrganizationResource, IO], + resource: Union[_models.OrganizationResource, IO[bytes]], **kwargs: Any - ) -> _models.OrganizationResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,7 +517,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OrganizationResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -543,7 +527,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(resource, "OrganizationResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, @@ -551,43 +535,39 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OrganizationResource", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } - @overload def begin_create_or_update( self, @@ -610,14 +590,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -629,7 +601,7 @@ def begin_create_or_update( self, resource_group_name: str, organization_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -642,18 +614,10 @@ def begin_create_or_update( :param organization_name: Name of the Organizations resource. Required. :type organization_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -665,7 +629,7 @@ def begin_create_or_update( self, resource_group_name: str, organization_name: str, - resource: Union[_models.OrganizationResource, IO], + resource: Union[_models.OrganizationResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OrganizationResource]: """Create a OrganizationResource. @@ -675,20 +639,9 @@ def begin_create_or_update( :type resource_group_name: str :param organization_name: Name of the Organizations resource. Required. :type organization_name: str - :param resource: Resource create parameters. Is either a OrganizationResource type or a IO - type. Required. - :type resource: ~azure.mgmt.astro.models.OrganizationResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param resource: Resource create parameters. Is either a OrganizationResource type or a + IO[bytes] type. Required. + :type resource: ~azure.mgmt.astro.models.OrganizationResource or IO[bytes] :return: An instance of LROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -715,12 +668,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = self._deserialize("OrganizationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -732,26 +686,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OrganizationResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return LROPoller[_models.OrganizationResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, organization_name: str, - properties: Union[_models.OrganizationResourceUpdate, IO], + properties: Union[_models.OrganizationResourceUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OrganizationResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -764,7 +716,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OrganizationResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -774,7 +726,7 @@ def _update_initial( else: _json = self._serialize.body(properties, "OrganizationResourceUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, @@ -782,42 +734,39 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OrganizationResource", pipeline_response) - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -841,14 +790,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -860,7 +801,7 @@ def begin_update( self, resource_group_name: str, organization_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -873,18 +814,10 @@ def begin_update( :param organization_name: Name of the Organizations resource. Required. :type organization_name: str :param properties: The resource properties to be updated. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -896,7 +829,7 @@ def begin_update( self, resource_group_name: str, organization_name: str, - properties: Union[_models.OrganizationResourceUpdate, IO], + properties: Union[_models.OrganizationResourceUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OrganizationResource]: """Update a OrganizationResource. @@ -907,19 +840,8 @@ def begin_update( :param organization_name: Name of the Organizations resource. Required. :type organization_name: str :param properties: The resource properties to be updated. Is either a - OrganizationResourceUpdate type or a IO type. Required. - :type properties: ~azure.mgmt.astro.models.OrganizationResourceUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + OrganizationResourceUpdate type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.astro.models.OrganizationResourceUpdate or IO[bytes] :return: An instance of LROPoller that returns either OrganizationResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.astro.models.OrganizationResource] @@ -946,12 +868,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OrganizationResource", pipeline_response) + deserialized = self._deserialize("OrganizationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -963,22 +886,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OrganizationResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return LROPoller[_models.OrganizationResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, organization_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -990,43 +909,46 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, organization_name=organization_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1037,14 +959,6 @@ def begin_delete(self, resource_group_name: str, organization_name: str, **kwarg :type resource_group_name: str :param organization_name: Name of the Organizations resource. Required. :type organization_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1058,7 +972,7 @@ def begin_delete(self, resource_group_name: str, organization_name: str, **kwarg lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, organization_name=organization_name, api_version=api_version, @@ -1067,11 +981,12 @@ def begin_delete(self, resource_group_name: str, organization_name: str, **kwarg params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1082,14 +997,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Astronomer.Astro/organizations/{organizationName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/operations_list_maximum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/operations_list_maximum_set_gen.py index 43701c62471e..1a87aa4a9d9a 100644 --- a/sdk/astro/azure-mgmt-astro/generated_samples/operations_list_maximum_set_gen.py +++ b/sdk/astro/azure-mgmt-astro/generated_samples/operations_list_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.astro import AstroMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Operations_List_MaximumSet_Gen.json +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Operations_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/operations_list_minimum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/operations_list_minimum_set_gen.py new file mode 100644 index 000000000000..4787d41b5352 --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_samples/operations_list_minimum_set_gen.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.astro import AstroMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-astro +# USAGE + python operations_list_minimum_set_gen.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 = AstroMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Operations_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_create_or_update_maximum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_create_or_update_maximum_set_gen.py index cd426bb4c137..a5a04bedef30 100644 --- a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_create_or_update_maximum_set_gen.py +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_create_or_update_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.astro import AstroMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = AstroMgmtClient( credential=DefaultAzureCredential(), - subscription_id="43454B17-172A-40FE-80FA-549EA23D12B3", + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", ) response = client.organizations.begin_create_or_update( @@ -34,40 +35,41 @@ def main(): organization_name="U.1-:7", resource={ "identity": {"type": "None", "userAssignedIdentities": {}}, - "location": "mhqthlsatwvqkl", + "location": "pgfkugslgnsxeqpjs", "properties": { "marketplace": { "offerDetails": { - "offerId": "krzkefmpxztqyusidzgpchfaswuyce", - "planId": "kndxzygsanuiqzwbfbbvoipv", - "planName": "pwqjwlq", - "publisherId": "gfsqxygpnerxmvols", - "termId": "pwds", - "termUnit": "xyygyzcazkuelz", + "offerId": "tvidibzbxevtvnrdp", + "planId": "lwcvzdqecwkeracahmixnh", + "planName": "d", + "publisherId": "kt", + "renewalMode": "Auto", + "termId": "kopnnjsp", + "termUnit": "rs", }, - "subscriptionId": "ntthclydlpqmasr", + "subscriptionId": "emasc", "subscriptionStatus": "PendingFulfillmentStart", }, "partnerOrganizationProperties": { - "organizationId": "lskgzdmziusgrsucv", - "organizationName": "3-", + "organizationId": "juomtfzwkjwnhhpodfnrqdv", + "organizationName": "U.1-:7", "singleSignOnProperties": { - "aadDomains": ["kfbleh"], - "enterpriseAppId": "mklfypyujwumgwdzae", + "aadDomains": ["fcnqoizqxcdclmy"], + "enterpriseAppId": "srkwxktx", "provisioningState": "Succeeded", "singleSignOnState": "Initial", - "singleSignOnUrl": "ymmtzkyghvinvhgnqlzwrr", + "singleSignOnUrl": "l", }, - "workspaceId": "vcrupxwpaba", + "workspaceId": "nnryjcmiohmkbvhngfgxigpodvhl", "workspaceName": "9.:06", }, "provisioningState": "Succeeded", "user": { "emailAddress": ".K_@e7N-g1.xjqnbPs", - "firstName": "nfh", - "lastName": "lazfbstcccykibvcrxpmglqam", - "phoneNumber": "inxkscllh", - "upn": "xtutvycpxjrtoftx", + "firstName": "ucowvrccqpqpkdg", + "lastName": "fwwtnwggrtibghoijfzajrhgyo", + "phoneNumber": "brnngpezmqecvflklbhsibq", + "upn": "zbdgbbqg", }, }, "tags": {}, @@ -76,6 +78,6 @@ def main(): print(response) -# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_CreateOrUpdate_MaximumSet_Gen.json +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_CreateOrUpdate_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_delete_maximum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_delete_maximum_set_gen.py index 579807be580a..94f34953b273 100644 --- a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_delete_maximum_set_gen.py +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.astro import AstroMgmtClient """ @@ -26,15 +27,15 @@ def main(): client = AstroMgmtClient( credential=DefaultAzureCredential(), - subscription_id="43454B17-172A-40FE-80FA-549EA23D12B3", + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", ) client.organizations.begin_delete( resource_group_name="rgastronomer", - organization_name="q:", + organization_name="U.1-:7", ).result() -# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_get_maximum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_get_maximum_set_gen.py index edbe5b43b1e4..bb13425792e0 100644 --- a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_get_maximum_set_gen.py +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.astro import AstroMgmtClient """ @@ -26,16 +27,16 @@ def main(): client = AstroMgmtClient( credential=DefaultAzureCredential(), - subscription_id="43454B17-172A-40FE-80FA-549EA23D12B3", + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", ) response = client.organizations.get( resource_group_name="rgastronomer", - organization_name="S PS", + organization_name="U.1-:7", ) print(response) -# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py index ea5e89589972..4dda22b302c3 100644 --- a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.astro import AstroMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = AstroMgmtClient( credential=DefaultAzureCredential(), - subscription_id="43454B17-172A-40FE-80FA-549EA23D12B3", + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", ) response = client.organizations.list_by_resource_group( @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_ListByResourceGroup_MaximumSet_Gen.json +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_ListByResourceGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py new file mode 100644 index 000000000000..d24a44eed450 --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.astro import AstroMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-astro +# USAGE + python organizations_list_by_resource_group_minimum_set_gen.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 = AstroMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", + ) + + response = client.organizations.list_by_resource_group( + resource_group_name="rgastronomer", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_ListByResourceGroup_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_maximum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_maximum_set_gen.py index f9b194728391..7bfdec695455 100644 --- a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_maximum_set_gen.py +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.astro import AstroMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = AstroMgmtClient( credential=DefaultAzureCredential(), - subscription_id="43454B17-172A-40FE-80FA-549EA23D12B3", + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", ) response = client.organizations.list_by_subscription() @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_ListBySubscription_MaximumSet_Gen.json +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_ListBySubscription_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_minimum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_minimum_set_gen.py new file mode 100644 index 000000000000..1f38b80ed073 --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_list_by_subscription_minimum_set_gen.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.astro import AstroMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-astro +# USAGE + python organizations_list_by_subscription_minimum_set_gen.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 = AstroMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", + ) + + response = client.organizations.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_ListBySubscription_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_update_maximum_set_gen.py b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_update_maximum_set_gen.py index 5ead3796668b..54b263f2c61a 100644 --- a/sdk/astro/azure-mgmt-astro/generated_samples/organizations_update_maximum_set_gen.py +++ b/sdk/astro/azure-mgmt-astro/generated_samples/organizations_update_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.astro import AstroMgmtClient """ @@ -26,42 +27,42 @@ def main(): client = AstroMgmtClient( credential=DefaultAzureCredential(), - subscription_id="43454B17-172A-40FE-80FA-549EA23D12B3", + subscription_id="A4679760-5C37-44EA-A4B8-8A7628B13824", ) response = client.organizations.begin_update( resource_group_name="rgastronomer", - organization_name="6.", + organization_name="U.1-:7", properties={ "identity": {"type": "None", "userAssignedIdentities": {}}, "properties": { "partnerOrganizationProperties": { - "organizationId": "lrtmbkvyvvoszhjevohkmyjhfyty", - "organizationName": "U2P_", + "organizationId": "fbjg", + "organizationName": "U.1-:7", "singleSignOnProperties": { - "aadDomains": ["kfbleh"], - "enterpriseAppId": "mklfypyujwumgwdzae", + "aadDomains": ["fcnqoizqxcdclmy"], + "enterpriseAppId": "srkwxktx", "provisioningState": "Succeeded", "singleSignOnState": "Initial", - "singleSignOnUrl": "ymmtzkyghvinvhgnqlzwrr", + "singleSignOnUrl": "l", }, - "workspaceId": "xsepuskdhejaadusyxq", - "workspaceName": "L.-y_--:", + "workspaceId": "ywwywdafdtvnntfevhnwszi", + "workspaceName": "9.:06", }, "user": { "emailAddress": ".K_@e7N-g1.xjqnbPs", - "firstName": "qeuofehzypzljgcuysugefbgxde", - "lastName": "g", - "phoneNumber": "aqpyxznvqpgkzohevynofrjdfgoo", - "upn": "uwtprzdfpsqmktx", + "firstName": "e", + "lastName": "puain", + "phoneNumber": "hepjqujjthtlxeoiltnchwqi", + "upn": "beyxdwtwshcujyjtowjdvgytygpp", }, }, - "tags": {"key1474": "bqqyipxnbbxryhznyaosmtpo"}, + "tags": {}, }, ).result() print(response) -# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Update_MaximumSet_Gen.json +# x-ms-original-file: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2024-08-27/examples/Organizations_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/astro/azure-mgmt-astro/generated_tests/conftest.py b/sdk/astro/azure-mgmt-astro/generated_tests/conftest.py new file mode 100644 index 000000000000..e62dc3980785 --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + astromgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + astromgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + astromgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + astromgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=astromgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=astromgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=astromgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=astromgmt_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations.py b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations.py new file mode 100644 index 000000000000..77c8f1d83f89 --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.astro import AstroMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAstroMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AstroMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-08-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations_async.py b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations_async.py new file mode 100644 index 000000000000..2acac54ec41b --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.astro.aio import AstroMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAstroMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AstroMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-08-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations.py b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations.py new file mode 100644 index 000000000000..cbe9c5ab622b --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations.py @@ -0,0 +1,177 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.astro import AstroMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAstroMgmtOrganizationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AstroMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.organizations.list_by_subscription( + api_version="2024-08-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.organizations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-08-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.organizations.get( + resource_group_name=resource_group.name, + organization_name="str", + api_version="2024-08-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.organizations.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + resource={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "marketplace": { + "offerDetails": { + "offerId": "str", + "planId": "str", + "publisherId": "str", + "endDate": "2020-02-20 00:00:00", + "planName": "str", + "renewalMode": "str", + "termId": "str", + "termUnit": "str", + }, + "subscriptionId": "str", + "subscriptionStatus": "str", + }, + "user": { + "emailAddress": "str", + "firstName": "str", + "lastName": "str", + "phoneNumber": "str", + "upn": "str", + }, + "partnerOrganizationProperties": { + "organizationName": "str", + "organizationId": "str", + "singleSignOnProperties": { + "aadDomains": ["str"], + "enterpriseAppId": "str", + "provisioningState": "str", + "singleSignOnState": "str", + "singleSignOnUrl": "str", + }, + "workspaceId": "str", + "workspaceName": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-08-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.organizations.begin_update( + resource_group_name=resource_group.name, + organization_name="str", + properties={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "partnerOrganizationProperties": { + "organizationId": "str", + "organizationName": "str", + "singleSignOnProperties": { + "aadDomains": ["str"], + "enterpriseAppId": "str", + "provisioningState": "str", + "singleSignOnState": "str", + "singleSignOnUrl": "str", + }, + "workspaceId": "str", + "workspaceName": "str", + }, + "user": { + "emailAddress": "str", + "firstName": "str", + "lastName": "str", + "phoneNumber": "str", + "upn": "str", + }, + }, + "tags": {"str": "str"}, + }, + api_version="2024-08-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.organizations.begin_delete( + resource_group_name=resource_group.name, + organization_name="str", + api_version="2024-08-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations_async.py b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations_async.py new file mode 100644 index 000000000000..1913437940af --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/generated_tests/test_astro_mgmt_organizations_operations_async.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.astro.aio import AstroMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAstroMgmtOrganizationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AstroMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.organizations.list_by_subscription( + api_version="2024-08-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.organizations.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-08-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.organizations.get( + resource_group_name=resource_group.name, + organization_name="str", + api_version="2024-08-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.organizations.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + resource={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "marketplace": { + "offerDetails": { + "offerId": "str", + "planId": "str", + "publisherId": "str", + "endDate": "2020-02-20 00:00:00", + "planName": "str", + "renewalMode": "str", + "termId": "str", + "termUnit": "str", + }, + "subscriptionId": "str", + "subscriptionStatus": "str", + }, + "user": { + "emailAddress": "str", + "firstName": "str", + "lastName": "str", + "phoneNumber": "str", + "upn": "str", + }, + "partnerOrganizationProperties": { + "organizationName": "str", + "organizationId": "str", + "singleSignOnProperties": { + "aadDomains": ["str"], + "enterpriseAppId": "str", + "provisioningState": "str", + "singleSignOnState": "str", + "singleSignOnUrl": "str", + }, + "workspaceId": "str", + "workspaceName": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-08-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.organizations.begin_update( + resource_group_name=resource_group.name, + organization_name="str", + properties={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "partnerOrganizationProperties": { + "organizationId": "str", + "organizationName": "str", + "singleSignOnProperties": { + "aadDomains": ["str"], + "enterpriseAppId": "str", + "provisioningState": "str", + "singleSignOnState": "str", + "singleSignOnUrl": "str", + }, + "workspaceId": "str", + "workspaceName": "str", + }, + "user": { + "emailAddress": "str", + "firstName": "str", + "lastName": "str", + "phoneNumber": "str", + "upn": "str", + }, + }, + "tags": {"str": "str"}, + }, + api_version="2024-08-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.organizations.begin_delete( + resource_group_name=resource_group.name, + organization_name="str", + api_version="2024-08-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/astro/azure-mgmt-astro/setup.py b/sdk/astro/azure-mgmt-astro/setup.py index bf27dbd806c2..59558aa7134b 100644 --- a/sdk/astro/azure-mgmt-astro/setup.py +++ b/sdk/astro/azure-mgmt-astro/setup.py @@ -74,9 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], python_requires=">=3.8", )