diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/README.md b/sdk/containerinstance/azure-mgmt-containerinstance/README.md index 6508a33173eb..05cdd4ccefa7 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/README.md +++ b/sdk/containerinstance/azure-mgmt-containerinstance/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Container Instance Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-containerinstance%2FREADME.png) diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json b/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json index 181a9b402e2f..670940ba988d 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json +++ b/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e716082ac474f182e2220e4f38f1d6191e7636cf", + "commit": "ddb267676bfb32e844dadcb0b7124838f4973852", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.8", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/containerinstance/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.4.8 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/containerinstance/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/containerinstance/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_configuration.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_configuration.py index 9db277825757..e6d0d7e3ff20 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_configuration.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_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 ContainerInstanceManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ContainerInstanceManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ContainerInstanceManagementClient. Note that all parameters used to create this instance are saved as instance @@ -30,14 +29,13 @@ class ContainerInstanceManagementClientConfiguration(Configuration): # pylint: :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ContainerInstanceManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-05-01") + api_version: str = kwargs.pop("api_version", "2024-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +47,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-containerinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py index ca0c4620cbbd..61918a6b5458 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import ContainerInstanceManagementClientConfiguration @@ -49,8 +52,8 @@ class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-v :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-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -66,7 +69,25 @@ def __init__( self._config = ContainerInstanceManagementClientConfiguration( 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) @@ -82,7 +103,7 @@ def __init__( 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 @@ -102,12 +123,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) -> "ContainerInstanceManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_patch.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_patch.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_serialization.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_serialization.py index 842ae727fbbc..8139854b97bb 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_serialization.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_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 @@ -662,12 +657,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -709,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) @@ -729,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: @@ -741,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -749,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -803,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) @@ -823,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) @@ -891,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +902,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -983,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) @@ -1160,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): @@ -1199,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:]) @@ -1220,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:]) @@ -1361,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, @@ -1381,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 @@ -1434,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 @@ -1471,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) @@ -1505,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 @@ -1568,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 @@ -1642,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) @@ -1690,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: @@ -1747,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"]: @@ -1798,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: @@ -1852,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): @@ -1883,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 @@ -1900,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): @@ -1935,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 @@ -1972,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 @@ -1988,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/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_vendor.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py index c1257f7f4e11..e5754a47ce68 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_configuration.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_configuration.py index 4492d81e388a..9f8a10dcbbdd 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_configuration.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/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 ContainerInstanceManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ContainerInstanceManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ContainerInstanceManagementClient. Note that all parameters used to create this instance are saved as instance @@ -30,14 +29,13 @@ class ContainerInstanceManagementClientConfiguration(Configuration): # pylint: :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ContainerInstanceManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-05-01") + api_version: str = kwargs.pop("api_version", "2024-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +47,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-containerinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py index 6f207cbe5d89..993388aa3598 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -50,8 +53,8 @@ class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-v :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-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -67,7 +70,25 @@ def __init__( self._config = ContainerInstanceManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -83,7 +104,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -103,12 +126,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "ContainerInstanceManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_patch.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_patch.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_operations.py index a9624d642e4c..0d3ad21bc9e4 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_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,23 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import ( + Any, + AsyncIterable, + AsyncIterator, + Callable, + Dict, + IO, + List, + Optional, + Type, + TypeVar, + Union, + cast, + overload, +) import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,12 +32,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 @@ -29,7 +46,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._container_groups_operations import ( build_create_or_update_request, build_delete_request, @@ -43,6 +59,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]] @@ -74,7 +94,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ContainerGroup"]: of each container group including containers, image registry credentials, restart policy, IP address type, OS type, state, and volumes. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContainerGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -86,7 +105,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ContainerGroup"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerGroupListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,15 +116,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ContainerGroup"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,13 +134,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("ContainerGroupListResult", pipeline_response) @@ -133,11 +149,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,8 +165,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -163,7 +177,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContainerGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -175,7 +188,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerGroupListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,16 +199,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 @@ -207,13 +218,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("ContainerGroupListResult", pipeline_response) @@ -223,11 +233,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 @@ -239,10 +249,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/Microsoft.ContainerInstance/containerGroups" - } - @distributed_trace_async async def get(self, resource_group_name: str, container_group_name: str, **kwargs: Any) -> _models.ContainerGroup: """Get the properties of the specified container group. @@ -255,12 +261,11 @@ async def get(self, resource_group_name: str, container_group_name: str, **kwarg :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,21 +279,19 @@ async def get(self, resource_group_name: str, container_group_name: str, **kwarg api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, container_group_name=container_group_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 @@ -297,25 +300,21 @@ async def get(self, resource_group_name: str, container_group_name: str, **kwarg map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, container_group_name: str, - container_group: Union[_models.ContainerGroup, IO], + container_group: Union[_models.ContainerGroup, IO[bytes]], **kwargs: Any - ) -> _models.ContainerGroup: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -328,17 +327,17 @@ 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.ContainerGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(container_group, (IO, bytes)): + if isinstance(container_group, (IOBase, bytes)): _content = container_group else: _json = self._serialize.body(container_group, "ContainerGroup") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, @@ -346,39 +345,34 @@ 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ContainerGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } - @overload async def begin_create_or_update( self, @@ -403,14 +397,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 ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -422,7 +408,7 @@ async def begin_create_or_update( self, resource_group_name: str, container_group_name: str, - container_group: IO, + container_group: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -437,18 +423,10 @@ async def begin_create_or_update( :type container_group_name: str :param container_group: The properties of the container group to be created or updated. Required. - :type container_group: IO + :type container_group: 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 ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -460,7 +438,7 @@ async def begin_create_or_update( self, resource_group_name: str, container_group_name: str, - container_group: Union[_models.ContainerGroup, IO], + container_group: Union[_models.ContainerGroup, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ContainerGroup]: """Create or update container groups. @@ -472,19 +450,8 @@ async def begin_create_or_update( :param container_group_name: The name of the container group. Required. :type container_group_name: str :param container_group: The properties of the container group to be created or updated. Is - either a ContainerGroup type or a IO type. Required. - :type container_group: ~azure.mgmt.containerinstance.models.ContainerGroup or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + either a ContainerGroup type or a IO[bytes] type. Required. + :type container_group: ~azure.mgmt.containerinstance.models.ContainerGroup or IO[bytes] :return: An instance of AsyncLROPoller that returns either ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -511,12 +478,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("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -526,17 +494,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ContainerGroup].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/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return AsyncLROPoller[_models.ContainerGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload async def update( @@ -561,7 +527,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -572,7 +537,7 @@ async def update( self, resource_group_name: str, container_group_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -586,11 +551,10 @@ async def update( :param container_group_name: The name of the container group. Required. :type container_group_name: str :param resource: The container group resource with just the tags to be updated. 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 :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -598,7 +562,11 @@ async def update( @distributed_trace_async async def update( - self, resource_group_name: str, container_group_name: str, resource: Union[_models.Resource, IO], **kwargs: Any + self, + resource_group_name: str, + container_group_name: str, + resource: Union[_models.Resource, IO[bytes]], + **kwargs: Any ) -> _models.ContainerGroup: """Update container groups. @@ -609,17 +577,13 @@ async def update( :param container_group_name: The name of the container group. Required. :type container_group_name: str :param resource: The container group resource with just the tags to be updated. Is either a - Resource type or a IO type. Required. - :type resource: ~azure.mgmt.containerinstance.models.Resource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + Resource type or a IO[bytes] type. Required. + :type resource: ~azure.mgmt.containerinstance.models.Resource or IO[bytes] :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -637,12 +601,12 @@ async def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IO, bytes)): + if isinstance(resource, (IOBase, bytes)): _content = resource else: _json = self._serialize.body(resource, "Resource") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, @@ -650,16 +614,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -668,21 +630,17 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return deserialized # type: ignore async def _delete_initial( self, resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> Optional[_models.ContainerGroup]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -694,43 +652,40 @@ async def _delete_initial( _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[Optional[_models.ContainerGroup]] = 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, container_group_name=container_group_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 [200, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -745,14 +700,6 @@ async def begin_delete( :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -776,12 +723,13 @@ 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): - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -791,22 +739,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ContainerGroup].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/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return AsyncLROPoller[_models.ContainerGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _restart_initial( # pylint: disable=inconsistent-return-statements + async def _restart_initial( self, resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -818,37 +764,40 @@ async def _restart_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_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata["url"], headers=_headers, 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 [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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart" - } + return deserialized # type: ignore @distributed_trace_async async def begin_restart( @@ -863,14 +812,6 @@ async def begin_restart( :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: 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: @@ -884,7 +825,7 @@ async def begin_restart( 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._restart_initial( # type: ignore + raw_result = await self._restart_initial( resource_group_name=resource_group_name, container_group_name=container_group_name, api_version=api_version, @@ -893,11 +834,12 @@ async def begin_restart( 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(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -906,17 +848,13 @@ 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_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -931,12 +869,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -950,21 +887,19 @@ async def stop( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -974,16 +909,12 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop" - } - - async def _start_initial( # pylint: disable=inconsistent-return-statements + async def _start_initial( self, resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -995,37 +926,40 @@ async def _start_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_start_request( + _request = build_start_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start" - } + return deserialized # type: ignore @distributed_trace_async async def begin_start( @@ -1040,14 +974,6 @@ async def begin_start( :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: 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: @@ -1061,7 +987,7 @@ async def begin_start( 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._start_initial( # type: ignore + raw_result = await self._start_initial( resource_group_name=resource_group_name, container_group_name=container_group_name, api_version=api_version, @@ -1070,11 +996,12 @@ async def begin_start( 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(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1083,17 +1010,13 @@ 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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long @@ -1108,12 +1031,11 @@ async def get_outbound_network_dependencies_endpoints( # pylint: disable=name-t :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of str or the result of cls(response) :rtype: list[str] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1127,21 +1049,19 @@ async def get_outbound_network_dependencies_endpoints( # pylint: disable=name-t api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[str]] = kwargs.pop("cls", None) - request = build_get_outbound_network_dependencies_endpoints_request( + _request = build_get_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_outbound_network_dependencies_endpoints.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1150,13 +1070,9 @@ async def get_outbound_network_dependencies_endpoints( # pylint: disable=name-t map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[str]", pipeline_response) + deserialized = self._deserialize("[str]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints" - } + return deserialized # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_operations.py index da3d40ac11c6..fbfbf408a608 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_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,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,20 +19,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._containers_operations import ( build_attach_request, build_execute_command_request, build_list_logs_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]] @@ -81,12 +85,11 @@ async def list_logs( :param timestamps: If true, adds a timestamp at the beginning of every line of log output. If not provided, defaults to false. Default value is None. :type timestamps: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: Logs or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.Logs :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,7 +103,7 @@ async def list_logs( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Logs] = kwargs.pop("cls", None) - request = build_list_logs_request( + _request = build_list_logs_request( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, @@ -108,16 +111,14 @@ async def list_logs( tail=tail, timestamps=timestamps, api_version=api_version, - template_url=self.list_logs.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -126,16 +127,12 @@ async def list_logs( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Logs", pipeline_response) + deserialized = self._deserialize("Logs", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_logs.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs" - } + return deserialized # type: ignore @overload async def execute_command( @@ -164,7 +161,6 @@ async def execute_command( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerExecResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +172,7 @@ async def execute_command( resource_group_name: str, container_group_name: str, container_name: str, - container_exec_request: IO, + container_exec_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -193,11 +189,10 @@ async def execute_command( :param container_name: The name of the container instance. Required. :type container_name: str :param container_exec_request: The request for the exec command. Required. - :type container_exec_request: IO + :type container_exec_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerExecResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -209,7 +204,7 @@ async def execute_command( resource_group_name: str, container_group_name: str, container_name: str, - container_exec_request: Union[_models.ContainerExecRequest, IO], + container_exec_request: Union[_models.ContainerExecRequest, IO[bytes]], **kwargs: Any ) -> _models.ContainerExecResponse: """Executes a command in a specific container instance. @@ -224,17 +219,14 @@ async def execute_command( :param container_name: The name of the container instance. Required. :type container_name: str :param container_exec_request: The request for the exec command. Is either a - ContainerExecRequest type or a IO type. Required. - :type container_exec_request: ~azure.mgmt.containerinstance.models.ContainerExecRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ContainerExecRequest type or a IO[bytes] type. Required. + :type container_exec_request: ~azure.mgmt.containerinstance.models.ContainerExecRequest or + IO[bytes] :return: ContainerExecResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -252,12 +244,12 @@ async def execute_command( content_type = content_type or "application/json" _json = None _content = None - if isinstance(container_exec_request, (IO, bytes)): + if isinstance(container_exec_request, (IOBase, bytes)): _content = container_exec_request else: _json = self._serialize.body(container_exec_request, "ContainerExecRequest") - request = build_execute_command_request( + _request = build_execute_command_request( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, @@ -266,16 +258,14 @@ async def execute_command( content_type=content_type, json=_json, content=_content, - template_url=self.execute_command.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -284,16 +274,12 @@ async def execute_command( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerExecResponse", pipeline_response) + deserialized = self._deserialize("ContainerExecResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - execute_command.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec" - } + return deserialized # type: ignore @distributed_trace_async async def attach( @@ -310,12 +296,11 @@ async def attach( :type container_group_name: str :param container_name: The name of the container instance. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerAttachResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerAttachResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -329,22 +314,20 @@ async def attach( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerAttachResponse] = kwargs.pop("cls", None) - request = build_attach_request( + _request = build_attach_request( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.attach.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -353,13 +336,9 @@ async def attach( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerAttachResponse", pipeline_response) + deserialized = self._deserialize("ContainerAttachResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - attach.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach" - } + return deserialized # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_operations.py index 8d9e6d6004da..87efb2567b29 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_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,20 +20,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._location_operations import ( build_list_cached_images_request, build_list_capabilities_request, build_list_usage_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]] @@ -62,7 +65,6 @@ def list_usage(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usa :param location: The identifier for the physical azure location. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -73,7 +75,7 @@ def list_usage(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usa api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,16 +86,14 @@ def list_usage(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usa def prepare_request(next_link=None): if not next_link: - request = build_list_usage_request( + _request = build_list_usage_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -105,13 +105,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("UsageListResult", pipeline_response) @@ -121,11 +120,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,10 +136,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages" - } - @distributed_trace def list_cached_images(self, location: str, **kwargs: Any) -> AsyncIterable["_models.CachedImages"]: """Get the list of cached images. @@ -149,7 +144,6 @@ def list_cached_images(self, location: str, **kwargs: Any) -> AsyncIterable["_mo :param location: The identifier for the physical azure location. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CachedImages or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.CachedImages] @@ -161,7 +155,7 @@ def list_cached_images(self, location: str, **kwargs: Any) -> AsyncIterable["_mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CachedImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,16 +166,14 @@ def list_cached_images(self, location: str, **kwargs: Any) -> AsyncIterable["_mo def prepare_request(next_link=None): if not next_link: - request = build_list_cached_images_request( + _request = build_list_cached_images_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cached_images.metadata["url"], 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 @@ -193,13 +185,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("CachedImagesListResult", pipeline_response) @@ -209,11 +200,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 @@ -225,10 +216,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_cached_images.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages" - } - @distributed_trace def list_capabilities(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Capabilities"]: """Get the list of capabilities of the location. @@ -237,7 +224,6 @@ def list_capabilities(self, location: str, **kwargs: Any) -> AsyncIterable["_mod :param location: The identifier for the physical azure location. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Capabilities or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.Capabilities] @@ -249,7 +235,7 @@ def list_capabilities(self, location: str, **kwargs: Any) -> AsyncIterable["_mod api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CapabilitiesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,16 +246,14 @@ def list_capabilities(self, location: str, **kwargs: Any) -> AsyncIterable["_mod def prepare_request(next_link=None): if not next_link: - request = build_list_capabilities_request( + _request = build_list_capabilities_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_capabilities.metadata["url"], 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 @@ -281,13 +265,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("CapabilitiesListResult", pipeline_response) @@ -297,11 +280,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 @@ -312,7 +295,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_capabilities.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities" - } diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_operations.py index c67943795cd1..ea2cd970a8d2 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/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 Azure Container Instance service. - :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.containerinstance.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 @@ -128,5 +127,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ContainerInstance/operations"} diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_subnet_service_association_link_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_subnet_service_association_link_operations.py index c113aac2d8f0..308458c82591 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_subnet_service_association_link_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_subnet_service_association_link_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,21 +15,25 @@ 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_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._subnet_service_association_link_operations import build_delete_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]] @@ -52,10 +57,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, virtual_network_name: str, subnet_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -67,38 +72,41 @@ 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, virtual_network_name=virtual_network_name, subnet_name=subnet_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 [200, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -115,14 +123,6 @@ async def begin_delete( :type virtual_network_name: str :param subnet_name: The name of the subnet. Required. :type subnet_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: @@ -136,7 +136,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, virtual_network_name=virtual_network_name, subnet_name=subnet_name, @@ -146,11 +146,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(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -159,14 +160,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/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py index 13597377f7bf..1f7cfa742d41 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py @@ -54,6 +54,7 @@ from ._models_py3 import ResourceLimits from ._models_py3 import ResourceRequests from ._models_py3 import ResourceRequirements +from ._models_py3 import SecretReference from ._models_py3 import SecurityContextCapabilitiesDefinition from ._models_py3 import SecurityContextDefinition from ._models_py3 import Usage @@ -129,6 +130,7 @@ "ResourceLimits", "ResourceRequests", "ResourceRequirements", + "SecretReference", "SecurityContextCapabilitiesDefinition", "SecurityContextDefinition", "Usage", diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py index ddc9e922ab73..cb62edb2c552 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py @@ -26,7 +26,7 @@ class AzureFileVolume(_serialization.Model): """The properties of the Azure File volume. Azure File shares are mounted as volumes. - 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 share_name: The name of the Azure File share to be mounted as a volume. Required. :vartype share_name: str @@ -38,6 +38,9 @@ class AzureFileVolume(_serialization.Model): :vartype storage_account_name: str :ivar storage_account_key: The storage account access key used to access the Azure File share. :vartype storage_account_key: str + :ivar storage_account_key_reference: The reference to the storage account access key used to + access the Azure File share. + :vartype storage_account_key_reference: str """ _validation = { @@ -50,6 +53,7 @@ class AzureFileVolume(_serialization.Model): "read_only": {"key": "readOnly", "type": "bool"}, "storage_account_name": {"key": "storageAccountName", "type": "str"}, "storage_account_key": {"key": "storageAccountKey", "type": "str"}, + "storage_account_key_reference": {"key": "storageAccountKeyReference", "type": "str"}, } def __init__( @@ -59,6 +63,7 @@ def __init__( storage_account_name: str, read_only: Optional[bool] = None, storage_account_key: Optional[str] = None, + storage_account_key_reference: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -73,18 +78,22 @@ def __init__( :keyword storage_account_key: The storage account access key used to access the Azure File share. :paramtype storage_account_key: str + :keyword storage_account_key_reference: The reference to the storage account access key used to + access the Azure File share. + :paramtype storage_account_key_reference: str """ super().__init__(**kwargs) self.share_name = share_name self.read_only = read_only self.storage_account_name = storage_account_name self.storage_account_key = storage_account_key + self.storage_account_key_reference = storage_account_key_reference class CachedImages(_serialization.Model): """The cached image and OS type. - 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 os_type: The OS type of the cached image. Required. :vartype os_type: str @@ -328,7 +337,7 @@ class Container(_serialization.Model): # pylint: disable=too-many-instance-attr 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 name: The user-provided name of the container instance. Required. :vartype name: str @@ -564,13 +573,16 @@ class ContainerGroupProperties(_serialization.Model): # pylint: disable=too-man 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 identity: The identity of the container group, if configured. :vartype identity: ~azure.mgmt.containerinstance.models.ContainerGroupIdentity :ivar provisioning_state: The provisioning state of the container group. This only appears in the response. :vartype provisioning_state: str + :ivar secret_references: The secret references that will be referenced within the container + group. + :vartype secret_references: list[~azure.mgmt.containerinstance.models.SecretReference] :ivar containers: The containers within the container group. Required. :vartype containers: list[~azure.mgmt.containerinstance.models.Container] :ivar image_registry_credentials: The image registry credentials by which the container group @@ -627,6 +639,7 @@ class ContainerGroupProperties(_serialization.Model): # pylint: disable=too-man _attribute_map = { "identity": {"key": "identity", "type": "ContainerGroupIdentity"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "secret_references": {"key": "properties.secretReferences", "type": "[SecretReference]"}, "containers": {"key": "properties.containers", "type": "[Container]"}, "image_registry_credentials": { "key": "properties.imageRegistryCredentials", @@ -657,6 +670,7 @@ def __init__( containers: List["_models.Container"], os_type: Union[str, "_models.OperatingSystemTypes"], identity: Optional["_models.ContainerGroupIdentity"] = None, + secret_references: Optional[List["_models.SecretReference"]] = None, image_registry_credentials: Optional[List["_models.ImageRegistryCredential"]] = None, restart_policy: Optional[Union[str, "_models.ContainerGroupRestartPolicy"]] = None, ip_address: Optional["_models.IpAddress"] = None, @@ -675,6 +689,9 @@ def __init__( """ :keyword identity: The identity of the container group, if configured. :paramtype identity: ~azure.mgmt.containerinstance.models.ContainerGroupIdentity + :keyword secret_references: The secret references that will be referenced within the container + group. + :paramtype secret_references: list[~azure.mgmt.containerinstance.models.SecretReference] :keyword containers: The containers within the container group. Required. :paramtype containers: list[~azure.mgmt.containerinstance.models.Container] :keyword image_registry_credentials: The image registry credentials by which the container @@ -721,6 +738,7 @@ def __init__( super().__init__(**kwargs) self.identity = identity self.provisioning_state = None + self.secret_references = secret_references self.containers = containers self.image_registry_credentials = image_registry_credentials self.restart_policy = restart_policy @@ -803,13 +821,16 @@ class ContainerGroup(Resource, ContainerGroupProperties): # pylint: disable=too 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 identity: The identity of the container group, if configured. :vartype identity: ~azure.mgmt.containerinstance.models.ContainerGroupIdentity :ivar provisioning_state: The provisioning state of the container group. This only appears in the response. :vartype provisioning_state: str + :ivar secret_references: The secret references that will be referenced within the container + group. + :vartype secret_references: list[~azure.mgmt.containerinstance.models.SecretReference] :ivar containers: The containers within the container group. Required. :vartype containers: list[~azure.mgmt.containerinstance.models.Container] :ivar image_registry_credentials: The image registry credentials by which the container group @@ -881,6 +902,7 @@ class ContainerGroup(Resource, ContainerGroupProperties): # pylint: disable=too _attribute_map = { "identity": {"key": "identity", "type": "ContainerGroupIdentity"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "secret_references": {"key": "properties.secretReferences", "type": "[SecretReference]"}, "containers": {"key": "properties.containers", "type": "[Container]"}, "image_registry_credentials": { "key": "properties.imageRegistryCredentials", @@ -917,6 +939,7 @@ def __init__( # pylint: disable=too-many-locals containers: List["_models.Container"], os_type: Union[str, "_models.OperatingSystemTypes"], identity: Optional["_models.ContainerGroupIdentity"] = None, + secret_references: Optional[List["_models.SecretReference"]] = None, image_registry_credentials: Optional[List["_models.ImageRegistryCredential"]] = None, restart_policy: Optional[Union[str, "_models.ContainerGroupRestartPolicy"]] = None, ip_address: Optional["_models.IpAddress"] = None, @@ -938,6 +961,9 @@ def __init__( # pylint: disable=too-many-locals """ :keyword identity: The identity of the container group, if configured. :paramtype identity: ~azure.mgmt.containerinstance.models.ContainerGroupIdentity + :keyword secret_references: The secret references that will be referenced within the container + group. + :paramtype secret_references: list[~azure.mgmt.containerinstance.models.SecretReference] :keyword containers: The containers within the container group. Required. :paramtype containers: list[~azure.mgmt.containerinstance.models.Container] :keyword image_registry_credentials: The image registry credentials by which the container @@ -992,6 +1018,7 @@ def __init__( # pylint: disable=too-many-locals tags=tags, zones=zones, identity=identity, + secret_references=secret_references, containers=containers, image_registry_credentials=image_registry_credentials, restart_policy=restart_policy, @@ -1011,6 +1038,7 @@ def __init__( # pylint: disable=too-many-locals ) self.identity = identity self.provisioning_state = None + self.secret_references = secret_references self.containers = containers self.image_registry_credentials = image_registry_credentials self.restart_policy = restart_policy @@ -1173,7 +1201,7 @@ def __init__(self, **kwargs: Any) -> None: class ContainerGroupSubnetId(_serialization.Model): """Container group subnet information. - 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: Resource ID of virtual network and subnet. Required. :vartype id: str @@ -1207,7 +1235,7 @@ def __init__( class ContainerHttpGet(_serialization.Model): """The container Http Get settings, for liveness or readiness probe. - 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 path: The path to probe. :vartype path: str @@ -1259,7 +1287,7 @@ def __init__( class ContainerPort(_serialization.Model): """The port exposed on the container instance. - 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 protocol: The protocol associated with the port. Known values are: "TCP" and "UDP". :vartype protocol: str or ~azure.mgmt.containerinstance.models.ContainerNetworkProtocol @@ -1442,7 +1470,7 @@ def __init__(self, **kwargs: Any) -> None: class DeploymentExtensionSpec(_serialization.Model): """Extension sidecars to be added to the deployment. - 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 name: Name of the extension. Required. :vartype name: str @@ -1501,7 +1529,7 @@ def __init__( class DnsConfiguration(_serialization.Model): """DNS configuration for the container group. - 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 name_servers: The DNS servers for the container group. Required. :vartype name_servers: list[str] @@ -1546,7 +1574,7 @@ def __init__( class EncryptionProperties(_serialization.Model): """The container group encryption properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar vault_base_url: The keyvault base url. Required. :vartype vault_base_url: str @@ -1594,7 +1622,7 @@ def __init__( class EnvironmentVariable(_serialization.Model): """The environment variable to set within the container instance. - 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 name: The name of the environment variable. Required. :vartype name: str @@ -1602,6 +1630,8 @@ class EnvironmentVariable(_serialization.Model): :vartype value: str :ivar secure_value: The value of the secure environment variable. :vartype secure_value: str + :ivar secure_value_reference: The reference of the secure environment variable. + :vartype secure_value_reference: str """ _validation = { @@ -1612,10 +1642,17 @@ class EnvironmentVariable(_serialization.Model): "name": {"key": "name", "type": "str"}, "value": {"key": "value", "type": "str"}, "secure_value": {"key": "secureValue", "type": "str"}, + "secure_value_reference": {"key": "secureValueReference", "type": "str"}, } def __init__( - self, *, name: str, value: Optional[str] = None, secure_value: Optional[str] = None, **kwargs: Any + self, + *, + name: str, + value: Optional[str] = None, + secure_value: Optional[str] = None, + secure_value_reference: Optional[str] = None, + **kwargs: Any ) -> None: """ :keyword name: The name of the environment variable. Required. @@ -1624,11 +1661,14 @@ def __init__( :paramtype value: str :keyword secure_value: The value of the secure environment variable. :paramtype secure_value: str + :keyword secure_value_reference: The reference of the secure environment variable. + :paramtype secure_value_reference: str """ super().__init__(**kwargs) self.name = name self.value = value self.secure_value = secure_value + self.secure_value_reference = secure_value_reference class Event(_serialization.Model): @@ -1682,7 +1722,7 @@ def __init__(self, **kwargs: Any) -> None: class GitRepoVolume(_serialization.Model): """Represents a volume that is populated with the contents of a git repository. - 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 directory: Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume @@ -1726,7 +1766,7 @@ def __init__( class GpuResource(_serialization.Model): """The GPU resource. - 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 count: The count of the GPU resource. Required. :vartype count: int @@ -1786,7 +1826,7 @@ def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, * class ImageRegistryCredential(_serialization.Model): """Image registry credential. - 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 server: The Docker image registry server without a protocol such as "http" and "https". Required. @@ -1795,6 +1835,8 @@ class ImageRegistryCredential(_serialization.Model): :vartype username: str :ivar password: The password for the private registry. :vartype password: str + :ivar password_reference: The reference for the private registry password. + :vartype password_reference: str :ivar identity: The identity for the private registry. :vartype identity: str :ivar identity_url: The identity URL for the private registry. @@ -1809,6 +1851,7 @@ class ImageRegistryCredential(_serialization.Model): "server": {"key": "server", "type": "str"}, "username": {"key": "username", "type": "str"}, "password": {"key": "password", "type": "str"}, + "password_reference": {"key": "passwordReference", "type": "str"}, "identity": {"key": "identity", "type": "str"}, "identity_url": {"key": "identityUrl", "type": "str"}, } @@ -1819,6 +1862,7 @@ def __init__( server: str, username: Optional[str] = None, password: Optional[str] = None, + password_reference: Optional[str] = None, identity: Optional[str] = None, identity_url: Optional[str] = None, **kwargs: Any @@ -1831,6 +1875,8 @@ def __init__( :paramtype username: str :keyword password: The password for the private registry. :paramtype password: str + :keyword password_reference: The reference for the private registry password. + :paramtype password_reference: str :keyword identity: The identity for the private registry. :paramtype identity: str :keyword identity_url: The identity URL for the private registry. @@ -1840,6 +1886,7 @@ def __init__( self.server = server self.username = username self.password = password + self.password_reference = password_reference self.identity = identity self.identity_url = identity_url @@ -1849,7 +1896,7 @@ class InitContainerDefinition(_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 name: The name for the init container. Required. :vartype name: str @@ -1919,7 +1966,7 @@ def __init__( self.security_context = security_context -class InitContainerPropertiesDefinitionInstanceView(_serialization.Model): +class InitContainerPropertiesDefinitionInstanceView(_serialization.Model): # pylint: disable=name-too-long """The instance view of the init container. Only valid in response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1962,7 +2009,7 @@ class IpAddress(_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 ports: The list of ports exposed on the container group. Required. :vartype ports: list[~azure.mgmt.containerinstance.models.Port] @@ -2047,7 +2094,7 @@ def __init__( class LogAnalytics(_serialization.Model): """Container group log analytics information. - 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 workspace_id: The workspace id for log analytics. Required. :vartype workspace_id: str @@ -2129,7 +2176,7 @@ def __init__(self, *, content: Optional[str] = None, **kwargs: Any) -> None: class Operation(_serialization.Model): """An operation for Azure Container Instance service. - 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 name: The name of the operation. Required. :vartype name: str @@ -2257,7 +2304,7 @@ def __init__( class Port(_serialization.Model): """The port exposed on the container group. - 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 protocol: The protocol associated with the port. Known values are: "TCP" and "UDP". :vartype protocol: str or ~azure.mgmt.containerinstance.models.ContainerGroupNetworkProtocol @@ -2334,7 +2381,7 @@ def __init__( class ResourceRequests(_serialization.Model): """The resource requests. - 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 memory_in_gb: The memory request in GB of this container instance. Required. :vartype memory_in_gb: float @@ -2375,7 +2422,7 @@ def __init__( class ResourceRequirements(_serialization.Model): """The resource requirements. - 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 requests: The resource requests of this container instance. Required. :vartype requests: ~azure.mgmt.containerinstance.models.ResourceRequests @@ -2406,6 +2453,48 @@ def __init__( self.limits = limits +class SecretReference(_serialization.Model): + """A secret reference. + + All required parameters must be populated in order to send to server. + + :ivar name: The identifier of the secret reference. Required. + :vartype name: str + :ivar identity: The ARM resource id of the managed identity that has access to the secret in + the key vault. Required. + :vartype identity: str + :ivar secret_reference_uri: The URI to the secret in key vault. Required. + :vartype secret_reference_uri: str + """ + + _validation = { + "name": {"required": True}, + "identity": {"required": True}, + "secret_reference_uri": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "secret_reference_uri": {"key": "secretReferenceUri", "type": "str"}, + } + + def __init__(self, *, name: str, identity: str, secret_reference_uri: str, **kwargs: Any) -> None: + """ + :keyword name: The identifier of the secret reference. Required. + :paramtype name: str + :keyword identity: The ARM resource id of the managed identity that has access to the secret in + the key vault. Required. + :paramtype identity: str + :keyword secret_reference_uri: The URI to the secret in key vault. Required. + :paramtype secret_reference_uri: str + """ + super().__init__(**kwargs) + self.name = name + self.identity = identity + self.secret_reference_uri = secret_reference_uri + + class SecurityContextCapabilitiesDefinition(_serialization.Model): """The capabilities to add or drop from a container. @@ -2626,7 +2715,7 @@ def __init__(self, **kwargs: Any) -> None: class Volume(_serialization.Model): """The properties of the volume. - 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 name: The name of the volume. Required. :vartype name: str @@ -2636,6 +2725,8 @@ class Volume(_serialization.Model): :vartype empty_dir: JSON :ivar secret: The secret volume. :vartype secret: dict[str, str] + :ivar secret_reference: The secret reference volume. + :vartype secret_reference: dict[str, str] :ivar git_repo: The git repo volume. :vartype git_repo: ~azure.mgmt.containerinstance.models.GitRepoVolume """ @@ -2649,6 +2740,7 @@ class Volume(_serialization.Model): "azure_file": {"key": "azureFile", "type": "AzureFileVolume"}, "empty_dir": {"key": "emptyDir", "type": "object"}, "secret": {"key": "secret", "type": "{str}"}, + "secret_reference": {"key": "secretReference", "type": "{str}"}, "git_repo": {"key": "gitRepo", "type": "GitRepoVolume"}, } @@ -2659,6 +2751,7 @@ def __init__( azure_file: Optional["_models.AzureFileVolume"] = None, empty_dir: Optional[JSON] = None, secret: Optional[Dict[str, str]] = None, + secret_reference: Optional[Dict[str, str]] = None, git_repo: Optional["_models.GitRepoVolume"] = None, **kwargs: Any ) -> None: @@ -2671,6 +2764,8 @@ def __init__( :paramtype empty_dir: JSON :keyword secret: The secret volume. :paramtype secret: dict[str, str] + :keyword secret_reference: The secret reference volume. + :paramtype secret_reference: dict[str, str] :keyword git_repo: The git repo volume. :paramtype git_repo: ~azure.mgmt.containerinstance.models.GitRepoVolume """ @@ -2679,13 +2774,14 @@ def __init__( self.azure_file = azure_file self.empty_dir = empty_dir self.secret = secret + self.secret_reference = secret_reference self.git_repo = git_repo class VolumeMount(_serialization.Model): """The properties of the volume mount. - 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 name: The name of the volume mount. Required. :vartype name: str diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_operations.py index afaa82772f27..71685e7b2e9c 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_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,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -15,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 @@ -29,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +48,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +59,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,7 +74,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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +87,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +118,7 @@ def build_get_request( "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -129,7 +135,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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,7 +150,7 @@ def build_create_or_update_request( "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,7 +169,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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -178,7 +184,7 @@ def build_update_request( "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -197,7 +203,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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +217,7 @@ def build_delete_request( "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -228,7 +234,7 @@ def build_restart_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -242,7 +248,7 @@ def build_restart_request( "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -259,7 +265,7 @@ def build_stop_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -273,7 +279,7 @@ def build_stop_request( "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -290,7 +296,7 @@ def build_start_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -304,7 +310,7 @@ def build_start_request( "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -321,7 +327,7 @@ def build_get_outbound_network_dependencies_endpoints_request( # pylint: disabl _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -335,7 +341,7 @@ def build_get_outbound_network_dependencies_endpoints_request( # pylint: disabl "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -373,7 +379,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.ContainerGroup"]: of each container group including containers, image registry credentials, restart policy, IP address type, OS type, state, and volumes. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContainerGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -384,7 +389,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ContainerGroup"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerGroupListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,15 +400,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ContainerGroup"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -415,13 +418,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("ContainerGroupListResult", pipeline_response) @@ -431,11 +433,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 @@ -447,8 +449,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ContainerGroup"]: """Get a list of container groups in the specified subscription and resource group. @@ -459,7 +459,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContainerGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -470,7 +469,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerGroupListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -481,16 +480,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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 @@ -502,13 +499,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("ContainerGroupListResult", pipeline_response) @@ -518,11 +514,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 @@ -534,10 +530,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups" - } - @distributed_trace def get(self, resource_group_name: str, container_group_name: str, **kwargs: Any) -> _models.ContainerGroup: """Get the properties of the specified container group. @@ -550,12 +542,11 @@ def get(self, resource_group_name: str, container_group_name: str, **kwargs: Any :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,21 +560,19 @@ def get(self, resource_group_name: str, container_group_name: str, **kwargs: Any api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, container_group_name=container_group_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 @@ -592,25 +581,21 @@ def get(self, resource_group_name: str, container_group_name: str, **kwargs: Any map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, container_group_name: str, - container_group: Union[_models.ContainerGroup, IO], + container_group: Union[_models.ContainerGroup, IO[bytes]], **kwargs: Any - ) -> _models.ContainerGroup: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -623,17 +608,17 @@ 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.ContainerGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(container_group, (IO, bytes)): + if isinstance(container_group, (IOBase, bytes)): _content = container_group else: _json = self._serialize.body(container_group, "ContainerGroup") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, @@ -641,39 +626,34 @@ 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ContainerGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } - @overload def begin_create_or_update( self, @@ -698,14 +678,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 ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -717,7 +689,7 @@ def begin_create_or_update( self, resource_group_name: str, container_group_name: str, - container_group: IO, + container_group: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -732,18 +704,10 @@ def begin_create_or_update( :type container_group_name: str :param container_group: The properties of the container group to be created or updated. Required. - :type container_group: IO + :type container_group: 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 ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -755,7 +719,7 @@ def begin_create_or_update( self, resource_group_name: str, container_group_name: str, - container_group: Union[_models.ContainerGroup, IO], + container_group: Union[_models.ContainerGroup, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ContainerGroup]: """Create or update container groups. @@ -767,19 +731,8 @@ def begin_create_or_update( :param container_group_name: The name of the container group. Required. :type container_group_name: str :param container_group: The properties of the container group to be created or updated. Is - either a ContainerGroup type or a IO type. Required. - :type container_group: ~azure.mgmt.containerinstance.models.ContainerGroup or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + either a ContainerGroup type or a IO[bytes] type. Required. + :type container_group: ~azure.mgmt.containerinstance.models.ContainerGroup or IO[bytes] :return: An instance of LROPoller that returns either ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -806,12 +759,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("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -821,17 +775,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ContainerGroup].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/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return LROPoller[_models.ContainerGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload def update( @@ -856,7 +808,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -867,7 +818,7 @@ def update( self, resource_group_name: str, container_group_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -881,11 +832,10 @@ def update( :param container_group_name: The name of the container group. Required. :type container_group_name: str :param resource: The container group resource with just the tags to be updated. 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 :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +843,11 @@ def update( @distributed_trace def update( - self, resource_group_name: str, container_group_name: str, resource: Union[_models.Resource, IO], **kwargs: Any + self, + resource_group_name: str, + container_group_name: str, + resource: Union[_models.Resource, IO[bytes]], + **kwargs: Any ) -> _models.ContainerGroup: """Update container groups. @@ -904,17 +858,13 @@ def update( :param container_group_name: The name of the container group. Required. :type container_group_name: str :param resource: The container group resource with just the tags to be updated. Is either a - Resource type or a IO type. Required. - :type resource: ~azure.mgmt.containerinstance.models.Resource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + Resource type or a IO[bytes] type. Required. + :type resource: ~azure.mgmt.containerinstance.models.Resource or IO[bytes] :return: ContainerGroup or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -932,12 +882,12 @@ def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IO, bytes)): + if isinstance(resource, (IOBase, bytes)): _content = resource else: _json = self._serialize.body(resource, "Resource") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, @@ -945,16 +895,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -963,21 +911,15 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return deserialized # type: ignore - def _delete_initial( - self, resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> Optional[_models.ContainerGroup]: - error_map = { + def _delete_initial(self, resource_group_name: str, container_group_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -989,43 +931,40 @@ def _delete_initial( _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[Optional[_models.ContainerGroup]] = 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, container_group_name=container_group_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 [200, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ContainerGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1040,14 +979,6 @@ def begin_delete( :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ContainerGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -1071,12 +1002,13 @@ def begin_delete( 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("ContainerGroup", pipeline_response) + deserialized = self._deserialize("ContainerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1086,22 +1018,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ContainerGroup].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/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" - } + return LROPoller[_models.ContainerGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _restart_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> None: - error_map = { + def _restart_initial(self, resource_group_name: str, container_group_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1113,37 +1041,40 @@ def _restart_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_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata["url"], headers=_headers, 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 [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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart" - } + return deserialized # type: ignore @distributed_trace def begin_restart(self, resource_group_name: str, container_group_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1156,14 +1087,6 @@ def begin_restart(self, resource_group_name: str, container_group_name: str, **k :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: 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: @@ -1177,7 +1100,7 @@ def begin_restart(self, resource_group_name: str, container_group_name: str, **k 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._restart_initial( # type: ignore + raw_result = self._restart_initial( resource_group_name=resource_group_name, container_group_name=container_group_name, api_version=api_version, @@ -1186,11 +1109,12 @@ def begin_restart(self, resource_group_name: str, container_group_name: str, **k 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(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1199,17 +1123,13 @@ 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_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -1224,12 +1144,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1243,21 +1162,19 @@ def stop( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1267,16 +1184,10 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore - def _start_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> None: - error_map = { + def _start_initial(self, resource_group_name: str, container_group_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1288,37 +1199,40 @@ def _start_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_start_request( + _request = build_start_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start" - } + return deserialized # type: ignore @distributed_trace def begin_start(self, resource_group_name: str, container_group_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1331,14 +1245,6 @@ def begin_start(self, resource_group_name: str, container_group_name: str, **kwa :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: 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: @@ -1352,7 +1258,7 @@ def begin_start(self, resource_group_name: str, container_group_name: str, **kwa 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._start_initial( # type: ignore + raw_result = self._start_initial( resource_group_name=resource_group_name, container_group_name=container_group_name, api_version=api_version, @@ -1361,11 +1267,12 @@ def begin_start(self, resource_group_name: str, container_group_name: str, **kwa 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(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1374,17 +1281,13 @@ 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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long @@ -1399,12 +1302,11 @@ def get_outbound_network_dependencies_endpoints( # pylint: disable=name-too-lon :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of str or the result of cls(response) :rtype: list[str] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1418,21 +1320,19 @@ def get_outbound_network_dependencies_endpoints( # pylint: disable=name-too-lon api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[str]] = kwargs.pop("cls", None) - request = build_get_outbound_network_dependencies_endpoints_request( + _request = build_get_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, container_group_name=container_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_outbound_network_dependencies_endpoints.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1441,13 +1341,9 @@ def get_outbound_network_dependencies_endpoints( # pylint: disable=name-too-lon map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[str]", pipeline_response) + deserialized = self._deserialize("[str]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints" - } + return deserialized # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_operations.py index 277332c3a654..cb5f7d6f94ae 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_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,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +51,7 @@ def build_list_logs_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +66,7 @@ def build_list_logs_request( "containerName": _SERIALIZER.url("container_name", container_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +87,7 @@ def build_execute_command_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +103,7 @@ def build_execute_command_request( "containerName": _SERIALIZER.url("container_name", container_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +122,7 @@ def build_attach_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +137,7 @@ def build_attach_request( "containerName": _SERIALIZER.url("container_name", container_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -190,12 +194,11 @@ def list_logs( :param timestamps: If true, adds a timestamp at the beginning of every line of log output. If not provided, defaults to false. Default value is None. :type timestamps: bool - :keyword callable cls: A custom type or function that will be passed the direct response :return: Logs or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.Logs :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,7 +212,7 @@ def list_logs( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Logs] = kwargs.pop("cls", None) - request = build_list_logs_request( + _request = build_list_logs_request( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, @@ -217,16 +220,14 @@ def list_logs( tail=tail, timestamps=timestamps, api_version=api_version, - template_url=self.list_logs.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,16 +236,12 @@ def list_logs( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Logs", pipeline_response) + deserialized = self._deserialize("Logs", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_logs.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs" - } + return deserialized # type: ignore @overload def execute_command( @@ -273,7 +270,6 @@ def execute_command( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerExecResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -285,7 +281,7 @@ def execute_command( resource_group_name: str, container_group_name: str, container_name: str, - container_exec_request: IO, + container_exec_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -302,11 +298,10 @@ def execute_command( :param container_name: The name of the container instance. Required. :type container_name: str :param container_exec_request: The request for the exec command. Required. - :type container_exec_request: IO + :type container_exec_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerExecResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -318,7 +313,7 @@ def execute_command( resource_group_name: str, container_group_name: str, container_name: str, - container_exec_request: Union[_models.ContainerExecRequest, IO], + container_exec_request: Union[_models.ContainerExecRequest, IO[bytes]], **kwargs: Any ) -> _models.ContainerExecResponse: """Executes a command in a specific container instance. @@ -333,17 +328,14 @@ def execute_command( :param container_name: The name of the container instance. Required. :type container_name: str :param container_exec_request: The request for the exec command. Is either a - ContainerExecRequest type or a IO type. Required. - :type container_exec_request: ~azure.mgmt.containerinstance.models.ContainerExecRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ContainerExecRequest type or a IO[bytes] type. Required. + :type container_exec_request: ~azure.mgmt.containerinstance.models.ContainerExecRequest or + IO[bytes] :return: ContainerExecResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -361,12 +353,12 @@ def execute_command( content_type = content_type or "application/json" _json = None _content = None - if isinstance(container_exec_request, (IO, bytes)): + if isinstance(container_exec_request, (IOBase, bytes)): _content = container_exec_request else: _json = self._serialize.body(container_exec_request, "ContainerExecRequest") - request = build_execute_command_request( + _request = build_execute_command_request( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, @@ -375,16 +367,14 @@ def execute_command( content_type=content_type, json=_json, content=_content, - template_url=self.execute_command.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +383,12 @@ def execute_command( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerExecResponse", pipeline_response) + deserialized = self._deserialize("ContainerExecResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - execute_command.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec" - } + return deserialized # type: ignore @distributed_trace def attach( @@ -419,12 +405,11 @@ def attach( :type container_group_name: str :param container_name: The name of the container instance. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContainerAttachResponse or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.ContainerAttachResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,22 +423,20 @@ def attach( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContainerAttachResponse] = kwargs.pop("cls", None) - request = build_attach_request( + _request = build_attach_request( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.attach.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -462,13 +445,9 @@ def attach( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContainerAttachResponse", pipeline_response) + deserialized = self._deserialize("ContainerAttachResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - attach.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach" - } + return deserialized # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py index c0cfe232e80a..9eef7fe6aceb 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_usage_request(location: str, subscription_id: str, **kwargs: Any) _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +56,7 @@ def build_list_usage_request(location: str, subscription_id: str, **kwargs: Any) "location": _SERIALIZER.url("location", location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,7 +71,7 @@ def build_list_cached_images_request(location: str, subscription_id: str, **kwar _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +84,7 @@ def build_list_cached_images_request(location: str, subscription_id: str, **kwar "location": _SERIALIZER.url("location", location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,7 +99,7 @@ def build_list_capabilities_request(location: str, subscription_id: str, **kwarg _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +112,7 @@ def build_list_capabilities_request(location: str, subscription_id: str, **kwarg "location": _SERIALIZER.url("location", location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +148,6 @@ def list_usage(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: :param location: The identifier for the physical azure location. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -156,7 +158,7 @@ def list_usage(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,16 +169,14 @@ def list_usage(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_usage_request( + _request = build_list_usage_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usage.metadata["url"], 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 @@ -188,13 +188,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("UsageListResult", pipeline_response) @@ -204,11 +203,11 @@ def extract_data(pipeline_response): return 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 @@ -220,10 +219,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages" - } - @distributed_trace def list_cached_images(self, location: str, **kwargs: Any) -> Iterable["_models.CachedImages"]: """Get the list of cached images. @@ -232,7 +227,6 @@ def list_cached_images(self, location: str, **kwargs: Any) -> Iterable["_models. :param location: The identifier for the physical azure location. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CachedImages or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.CachedImages] :raises ~azure.core.exceptions.HttpResponseError: @@ -243,7 +237,7 @@ def list_cached_images(self, location: str, **kwargs: Any) -> Iterable["_models. api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CachedImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,16 +248,14 @@ def list_cached_images(self, location: str, **kwargs: Any) -> Iterable["_models. def prepare_request(next_link=None): if not next_link: - request = build_list_cached_images_request( + _request = build_list_cached_images_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cached_images.metadata["url"], 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 @@ -275,13 +267,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("CachedImagesListResult", pipeline_response) @@ -291,11 +282,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 @@ -307,10 +298,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_cached_images.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages" - } - @distributed_trace def list_capabilities(self, location: str, **kwargs: Any) -> Iterable["_models.Capabilities"]: """Get the list of capabilities of the location. @@ -319,7 +306,6 @@ def list_capabilities(self, location: str, **kwargs: Any) -> Iterable["_models.C :param location: The identifier for the physical azure location. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Capabilities or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.Capabilities] :raises ~azure.core.exceptions.HttpResponseError: @@ -330,7 +316,7 @@ def list_capabilities(self, location: str, **kwargs: Any) -> Iterable["_models.C api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CapabilitiesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,16 +327,14 @@ def list_capabilities(self, location: str, **kwargs: Any) -> Iterable["_models.C def prepare_request(next_link=None): if not next_link: - request = build_list_capabilities_request( + _request = build_list_capabilities_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_capabilities.metadata["url"], 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 @@ -362,13 +346,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("CapabilitiesListResult", pipeline_response) @@ -378,11 +361,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 @@ -393,7 +376,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_capabilities.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities" - } diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_operations.py index 3252348a0655..2a655d4f3086 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) 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 Azure Container Instance service. - :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.containerinstance.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 @@ -150,5 +149,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ContainerInstance/operations"} diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_subnet_service_association_link_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_subnet_service_association_link_operations.py index d61100345adb..93e8707fabb2 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_subnet_service_association_link_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_subnet_service_association_link_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterator, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) 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 @@ -27,8 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,7 +62,7 @@ def build_delete_request( "subnetName": _SERIALIZER.url("subnet_name", subnet_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,10 +92,10 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, virtual_network_name: str, subnet_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,38 +107,41 @@ 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, virtual_network_name=virtual_network_name, subnet_name=subnet_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 [200, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -150,14 +158,6 @@ def begin_delete( :type virtual_network_name: str :param subnet_name: The name of the subnet. Required. :type subnet_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: @@ -171,7 +171,7 @@ 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 = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, subnet_name=subnet_name, @@ -181,11 +181,12 @@ def begin_delete( 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(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -194,14 +195,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/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/cached_images_list.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/cached_images_list.py index 8b7cd6445d03..48083823bb78 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/cached_images_list.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/cached_images_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/CachedImagesList.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/CachedImagesList.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/capabilities_list.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/capabilities_list.py index a87b989cd4f5..c6cc6c3a3ff4 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/capabilities_list.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/capabilities_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/CapabilitiesList.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/CapabilitiesList.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_attach.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_attach.py index bf224a5d78c8..952e7a76276d 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_attach.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_attach.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerAttach.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerAttach.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_exec.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_exec.py index 48af00573a2e..5c4e4c7ff5d3 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_exec.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_exec.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerExec.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerExec.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_create_confidential.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_create_confidential.py index 14f41f58f69d..36f53fc1a99f 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_create_confidential.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_create_confidential.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -61,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupCreateConfidential.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupCreateConfidential.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_encryption_properties.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_encryption_properties.py index f037ed962287..67e32e5be628 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_encryption_properties.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_encryption_properties.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -68,6 +69,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupEncryptionProperties.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupEncryptionProperties.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_extensions.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_extensions.py index 8366013d9cdb..c9ae2a673dc0 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_extensions.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_extensions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -76,6 +77,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupExtensions.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupExtensions.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_usage.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_usage.py index 6cf542b0f18c..cf705cfab525 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_usage.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupUsage.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupUsage.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_or_update.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_or_update.py index c91b5967b174..ad6054fea171 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_or_update.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -106,6 +107,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsCreateOrUpdate.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_or_update_secret_reference.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_or_update_secret_reference.py new file mode 100644 index 000000000000..84b976f1b85b --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_or_update_secret_reference.py @@ -0,0 +1,141 @@ +# 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.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_groups_create_or_update_secret_reference.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 = ContainerInstanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.container_groups.begin_create_or_update( + resource_group_name="demo", + container_group_name="demo1", + container_group={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {} + }, + }, + "location": "west us", + "properties": { + "containers": [ + { + "name": "demo1", + "properties": { + "command": [], + "environmentVariables": [{"name": "envSecret", "secureValueReference": "envSecretRef"}], + "image": "privateRegistryImage", + "ports": [{"port": 80}], + "resources": {"requests": {"cpu": 1, "gpu": {"count": 1, "sku": "K80"}, "memoryInGB": 1.5}}, + "volumeMounts": [ + {"mountPath": "/mnt/volume1", "name": "volume1", "readOnly": False}, + {"mountPath": "/mnt/volume2", "name": "volume2", "readOnly": False}, + {"mountPath": "/mnt/volume3", "name": "volume3", "readOnly": True}, + ], + }, + } + ], + "diagnostics": { + "logAnalytics": { + "logType": "ContainerInsights", + "metadata": {"test-key": "test-metadata-value"}, + "workspaceId": "workspaceid", + "workspaceKey": "workspaceKey", + "workspaceResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace", + } + }, + "dnsConfig": { + "nameServers": ["1.1.1.1"], + "options": "ndots:2", + "searchDomains": "cluster.local svc.cluster.local", + }, + "imageRegistryCredentials": [ + { + "passwordReference": "privateRegistryKeyRef", + "server": "demoregistry.azurecr.io", + "username": "registryUserName", + } + ], + "ipAddress": { + "autoGeneratedDomainNameLabelScope": "Unsecure", + "dnsNameLabel": "dnsnamelabel1", + "ports": [{"port": 80, "protocol": "TCP"}], + "type": "Public", + }, + "osType": "Linux", + "secretReferences": [ + { + "identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name", + "name": "envSecretRef", + "secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/envSecret", + }, + { + "identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name", + "name": "accountKeyRef", + "secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/accountKey", + }, + { + "identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name", + "name": "volumeSecretRef", + "secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/volumeSecret", + }, + { + "identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name", + "name": "privateRegistryKeyRef", + "secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/privateRegistryKey", + }, + ], + "subnetIds": [ + { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]" + } + ], + "volumes": [ + { + "azureFile": { + "shareName": "shareName", + "storageAccountKeyReference": "accountKeyRef", + "storageAccountName": "accountName", + }, + "name": "volume1", + }, + {"emptyDir": {}, "name": "volume2"}, + { + "name": "volume3", + "secret": {"secretKey1": "SecretValue1InBase64"}, + "secretReference": {"secretKey2": "volumeSecretRef"}, + }, + ], + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsCreateOrUpdateSecretReference.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_priority.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_priority.py index 669feee2cb7b..98905f90121f 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_priority.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_create_priority.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -55,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsCreatePriority.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsCreatePriority.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_delete.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_delete.py index b668f351e487..7128465cc3e0 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_delete.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsDelete.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsDelete.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_failed.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_failed.py index acb5bdddb7d0..a041fa53c0f7 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_failed.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_failed.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsGet_Failed.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsGet_Failed.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_priority.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_priority.py index 80b590ce3948..c21046abb406 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_priority.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_priority.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsGetPriority.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsGetPriority.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_succeeded.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_succeeded.py index 32cd7a87ccc4..bad78bc15c4c 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_succeeded.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_get_succeeded.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsGet_Succeeded.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsGet_Succeeded.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list.py index e045d4755eb4..1e5319f02594 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsList.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsList.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list_by_resource_group.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list_by_resource_group.py index 1004d47e11e2..356b18aef23f 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list_by_resource_group.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsListByResourceGroup.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_restart.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_restart.py index e26484aa3519..6d65424ee93f 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_restart.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_restart.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="subid", ) - response = client.container_groups.begin_restart( + client.container_groups.begin_restart( resource_group_name="demo", container_group_name="demo1", ).result() - print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsRestart.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsRestart.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_start.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_start.py index 0ba41154670a..8a7a492db63c 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_start.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_start.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="subid", ) - response = client.container_groups.begin_start( + client.container_groups.begin_start( resource_group_name="demo", container_group_name="demo1", ).result() - print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsStart.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsStart.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_stop.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_stop.py index 58c6a41b9992..9a7c6238f348 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_stop.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_stop.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="subid", ) - response = client.container_groups.stop( + client.container_groups.stop( resource_group_name="demo", container_group_name="demo1", ) - print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsStop.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerGroupsStop.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_list_logs.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_list_logs.py index 4328f098b5a2..ee6725e8df05 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_list_logs.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_list_logs.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerListLogs.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/ContainerListLogs.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/operations_list.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/operations_list.py index eaf5f595d3fd..491ca3c9c204 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/operations_list.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/OperationsList.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/subnet_service_association_link_delete.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/subnet_service_association_link_delete.py index 6d45c381ce37..15febf5b670c 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/subnet_service_association_link_delete.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/subnet_service_association_link_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.containerinstance import ContainerInstanceManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.subnet_service_association_link.begin_delete( + client.subnet_service_association_link.begin_delete( resource_group_name="demo", virtual_network_name="demo2", subnet_name="demo3", ).result() - print(response) -# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/SubnetServiceAssociationLinkDelete.json +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-10-01-preview/examples/SubnetServiceAssociationLinkDelete.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/conftest.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/conftest.py new file mode 100644 index 000000000000..e965bd77cfd7 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/conftest.py @@ -0,0 +1,47 @@ +# 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): + containerinstancemanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + containerinstancemanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + containerinstancemanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + containerinstancemanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=containerinstancemanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=containerinstancemanagement_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=containerinstancemanagement_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=containerinstancemanagement_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/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations.py new file mode 100644 index 000000000000..a517e1dcc7b2 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations.py @@ -0,0 +1,357 @@ +# 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.containerinstance import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementContainerGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.container_groups.list( + api_version="2024-10-01-preview", + ) + 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.container_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01-preview", + ) + 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.container_groups.get( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + + # 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.container_groups.begin_create_or_update( + resource_group_name=resource_group.name, + container_group_name="str", + container_group={ + "containers": [ + { + "image": "str", + "name": "str", + "resources": { + "requests": {"cpu": 0.0, "memoryInGB": 0.0, "gpu": {"count": 0, "sku": "str"}}, + "limits": {"cpu": 0.0, "gpu": {"count": 0, "sku": "str"}, "memoryInGB": 0.0}, + }, + "command": ["str"], + "environmentVariables": [ + {"name": "str", "secureValue": "str", "secureValueReference": "str", "value": "str"} + ], + "instanceView": { + "currentState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "events": [ + { + "count": 0, + "firstTimestamp": "2020-02-20 00:00:00", + "lastTimestamp": "2020-02-20 00:00:00", + "message": "str", + "name": "str", + "type": "str", + } + ], + "previousState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "restartCount": 0, + }, + "livenessProbe": { + "exec": {"command": ["str"]}, + "failureThreshold": 0, + "httpGet": { + "port": 0, + "httpHeaders": [{"name": "str", "value": "str"}], + "path": "str", + "scheme": "str", + }, + "initialDelaySeconds": 0, + "periodSeconds": 0, + "successThreshold": 0, + "timeoutSeconds": 0, + }, + "ports": [{"port": 0, "protocol": "str"}], + "readinessProbe": { + "exec": {"command": ["str"]}, + "failureThreshold": 0, + "httpGet": { + "port": 0, + "httpHeaders": [{"name": "str", "value": "str"}], + "path": "str", + "scheme": "str", + }, + "initialDelaySeconds": 0, + "periodSeconds": 0, + "successThreshold": 0, + "timeoutSeconds": 0, + }, + "securityContext": { + "allowPrivilegeEscalation": bool, + "capabilities": {"add": ["str"], "drop": ["str"]}, + "privileged": bool, + "runAsGroup": 0, + "runAsUser": 0, + "seccompProfile": "str", + }, + "volumeMounts": [{"mountPath": "str", "name": "str", "readOnly": bool}], + } + ], + "osType": "str", + "confidentialComputeProperties": {"ccePolicy": "str"}, + "diagnostics": { + "logAnalytics": { + "workspaceId": "str", + "workspaceKey": "str", + "logType": "str", + "metadata": {"str": "str"}, + "workspaceResourceId": "str", + } + }, + "dnsConfig": {"nameServers": ["str"], "options": "str", "searchDomains": "str"}, + "encryptionProperties": { + "keyName": "str", + "keyVersion": "str", + "vaultBaseUrl": "str", + "identity": "str", + }, + "extensions": [ + {"name": "str", "extensionType": "str", "protectedSettings": {}, "settings": {}, "version": "str"} + ], + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "imageRegistryCredentials": [ + { + "server": "str", + "identity": "str", + "identityUrl": "str", + "password": "str", + "passwordReference": "str", + "username": "str", + } + ], + "initContainers": [ + { + "name": "str", + "command": ["str"], + "environmentVariables": [ + {"name": "str", "secureValue": "str", "secureValueReference": "str", "value": "str"} + ], + "image": "str", + "instanceView": { + "currentState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "events": [ + { + "count": 0, + "firstTimestamp": "2020-02-20 00:00:00", + "lastTimestamp": "2020-02-20 00:00:00", + "message": "str", + "name": "str", + "type": "str", + } + ], + "previousState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "restartCount": 0, + }, + "securityContext": { + "allowPrivilegeEscalation": bool, + "capabilities": {"add": ["str"], "drop": ["str"]}, + "privileged": bool, + "runAsGroup": 0, + "runAsUser": 0, + "seccompProfile": "str", + }, + "volumeMounts": [{"mountPath": "str", "name": "str", "readOnly": bool}], + } + ], + "instanceView": { + "events": [ + { + "count": 0, + "firstTimestamp": "2020-02-20 00:00:00", + "lastTimestamp": "2020-02-20 00:00:00", + "message": "str", + "name": "str", + "type": "str", + } + ], + "state": "str", + }, + "ipAddress": { + "ports": [{"port": 0, "protocol": "str"}], + "type": "str", + "autoGeneratedDomainNameLabelScope": "Unsecure", + "dnsNameLabel": "str", + "fqdn": "str", + "ip": "str", + }, + "location": "str", + "name": "str", + "priority": "str", + "provisioningState": "str", + "restartPolicy": "str", + "secretReferences": [{"identity": "str", "name": "str", "secretReferenceUri": "str"}], + "sku": "str", + "subnetIds": [{"id": "str", "name": "str"}], + "tags": {"str": "str"}, + "type": "str", + "volumes": [ + { + "name": "str", + "azureFile": { + "shareName": "str", + "storageAccountName": "str", + "readOnly": bool, + "storageAccountKey": "str", + "storageAccountKeyReference": "str", + }, + "emptyDir": {}, + "gitRepo": {"repository": "str", "directory": "str", "revision": "str"}, + "secret": {"str": "str"}, + "secretReference": {"str": "str"}, + } + ], + "zones": ["str"], + }, + api_version="2024-10-01-preview", + ).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_update(self, resource_group): + response = self.client.container_groups.update( + resource_group_name=resource_group.name, + container_group_name="str", + resource={ + "id": "str", + "location": "str", + "name": "str", + "tags": {"str": "str"}, + "type": "str", + "zones": ["str"], + }, + api_version="2024-10-01-preview", + ) + + # 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.container_groups.begin_delete( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ).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_restart(self, resource_group): + response = self.client.container_groups.begin_restart( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ).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_stop(self, resource_group): + response = self.client.container_groups.stop( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_start(self, resource_group): + response = self.client.container_groups.begin_start( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ).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_get_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.container_groups.get_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations_async.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations_async.py new file mode 100644 index 000000000000..789512890548 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations_async.py @@ -0,0 +1,372 @@ +# 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.containerinstance.aio import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementContainerGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.container_groups.list( + api_version="2024-10-01-preview", + ) + 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.container_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01-preview", + ) + 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.container_groups.get( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + + # 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.container_groups.begin_create_or_update( + resource_group_name=resource_group.name, + container_group_name="str", + container_group={ + "containers": [ + { + "image": "str", + "name": "str", + "resources": { + "requests": {"cpu": 0.0, "memoryInGB": 0.0, "gpu": {"count": 0, "sku": "str"}}, + "limits": {"cpu": 0.0, "gpu": {"count": 0, "sku": "str"}, "memoryInGB": 0.0}, + }, + "command": ["str"], + "environmentVariables": [ + {"name": "str", "secureValue": "str", "secureValueReference": "str", "value": "str"} + ], + "instanceView": { + "currentState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "events": [ + { + "count": 0, + "firstTimestamp": "2020-02-20 00:00:00", + "lastTimestamp": "2020-02-20 00:00:00", + "message": "str", + "name": "str", + "type": "str", + } + ], + "previousState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "restartCount": 0, + }, + "livenessProbe": { + "exec": {"command": ["str"]}, + "failureThreshold": 0, + "httpGet": { + "port": 0, + "httpHeaders": [{"name": "str", "value": "str"}], + "path": "str", + "scheme": "str", + }, + "initialDelaySeconds": 0, + "periodSeconds": 0, + "successThreshold": 0, + "timeoutSeconds": 0, + }, + "ports": [{"port": 0, "protocol": "str"}], + "readinessProbe": { + "exec": {"command": ["str"]}, + "failureThreshold": 0, + "httpGet": { + "port": 0, + "httpHeaders": [{"name": "str", "value": "str"}], + "path": "str", + "scheme": "str", + }, + "initialDelaySeconds": 0, + "periodSeconds": 0, + "successThreshold": 0, + "timeoutSeconds": 0, + }, + "securityContext": { + "allowPrivilegeEscalation": bool, + "capabilities": {"add": ["str"], "drop": ["str"]}, + "privileged": bool, + "runAsGroup": 0, + "runAsUser": 0, + "seccompProfile": "str", + }, + "volumeMounts": [{"mountPath": "str", "name": "str", "readOnly": bool}], + } + ], + "osType": "str", + "confidentialComputeProperties": {"ccePolicy": "str"}, + "diagnostics": { + "logAnalytics": { + "workspaceId": "str", + "workspaceKey": "str", + "logType": "str", + "metadata": {"str": "str"}, + "workspaceResourceId": "str", + } + }, + "dnsConfig": {"nameServers": ["str"], "options": "str", "searchDomains": "str"}, + "encryptionProperties": { + "keyName": "str", + "keyVersion": "str", + "vaultBaseUrl": "str", + "identity": "str", + }, + "extensions": [ + { + "name": "str", + "extensionType": "str", + "protectedSettings": {}, + "settings": {}, + "version": "str", + } + ], + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "imageRegistryCredentials": [ + { + "server": "str", + "identity": "str", + "identityUrl": "str", + "password": "str", + "passwordReference": "str", + "username": "str", + } + ], + "initContainers": [ + { + "name": "str", + "command": ["str"], + "environmentVariables": [ + {"name": "str", "secureValue": "str", "secureValueReference": "str", "value": "str"} + ], + "image": "str", + "instanceView": { + "currentState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "events": [ + { + "count": 0, + "firstTimestamp": "2020-02-20 00:00:00", + "lastTimestamp": "2020-02-20 00:00:00", + "message": "str", + "name": "str", + "type": "str", + } + ], + "previousState": { + "detailStatus": "str", + "exitCode": 0, + "finishTime": "2020-02-20 00:00:00", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "restartCount": 0, + }, + "securityContext": { + "allowPrivilegeEscalation": bool, + "capabilities": {"add": ["str"], "drop": ["str"]}, + "privileged": bool, + "runAsGroup": 0, + "runAsUser": 0, + "seccompProfile": "str", + }, + "volumeMounts": [{"mountPath": "str", "name": "str", "readOnly": bool}], + } + ], + "instanceView": { + "events": [ + { + "count": 0, + "firstTimestamp": "2020-02-20 00:00:00", + "lastTimestamp": "2020-02-20 00:00:00", + "message": "str", + "name": "str", + "type": "str", + } + ], + "state": "str", + }, + "ipAddress": { + "ports": [{"port": 0, "protocol": "str"}], + "type": "str", + "autoGeneratedDomainNameLabelScope": "Unsecure", + "dnsNameLabel": "str", + "fqdn": "str", + "ip": "str", + }, + "location": "str", + "name": "str", + "priority": "str", + "provisioningState": "str", + "restartPolicy": "str", + "secretReferences": [{"identity": "str", "name": "str", "secretReferenceUri": "str"}], + "sku": "str", + "subnetIds": [{"id": "str", "name": "str"}], + "tags": {"str": "str"}, + "type": "str", + "volumes": [ + { + "name": "str", + "azureFile": { + "shareName": "str", + "storageAccountName": "str", + "readOnly": bool, + "storageAccountKey": "str", + "storageAccountKeyReference": "str", + }, + "emptyDir": {}, + "gitRepo": {"repository": "str", "directory": "str", "revision": "str"}, + "secret": {"str": "str"}, + "secretReference": {"str": "str"}, + } + ], + "zones": ["str"], + }, + api_version="2024-10-01-preview", + ) + ).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_update(self, resource_group): + response = await self.client.container_groups.update( + resource_group_name=resource_group.name, + container_group_name="str", + resource={ + "id": "str", + "location": "str", + "name": "str", + "tags": {"str": "str"}, + "type": "str", + "zones": ["str"], + }, + api_version="2024-10-01-preview", + ) + + # 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.container_groups.begin_delete( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + ).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_restart(self, resource_group): + response = await ( + await self.client.container_groups.begin_restart( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + ).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_stop(self, resource_group): + response = await self.client.container_groups.stop( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_start(self, resource_group): + response = await ( + await self.client.container_groups.begin_start( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + ).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_get_outbound_network_dependencies_endpoints(self, resource_group): + response = await self.client.container_groups.get_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + container_group_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_containers_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_containers_operations.py new file mode 100644 index 000000000000..53c134806d88 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_containers_operations.py @@ -0,0 +1,59 @@ +# 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.containerinstance import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementContainersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_logs(self, resource_group): + response = self.client.containers.list_logs( + resource_group_name=resource_group.name, + container_group_name="str", + container_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_execute_command(self, resource_group): + response = self.client.containers.execute_command( + resource_group_name=resource_group.name, + container_group_name="str", + container_name="str", + container_exec_request={"command": "str", "terminalSize": {"cols": 0, "rows": 0}}, + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attach(self, resource_group): + response = self.client.containers.attach( + resource_group_name=resource_group.name, + container_group_name="str", + container_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_containers_operations_async.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_containers_operations_async.py new file mode 100644 index 000000000000..fcc64f6f0f3a --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_containers_operations_async.py @@ -0,0 +1,60 @@ +# 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.containerinstance.aio import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementContainersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_logs(self, resource_group): + response = await self.client.containers.list_logs( + resource_group_name=resource_group.name, + container_group_name="str", + container_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_execute_command(self, resource_group): + response = await self.client.containers.execute_command( + resource_group_name=resource_group.name, + container_group_name="str", + container_name="str", + container_exec_request={"command": "str", "terminalSize": {"cols": 0, "rows": 0}}, + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attach(self, resource_group): + response = await self.client.containers.attach( + resource_group_name=resource_group.name, + container_group_name="str", + container_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_location_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_location_operations.py new file mode 100644 index 000000000000..661136201327 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_location_operations.py @@ -0,0 +1,52 @@ +# 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.containerinstance import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementLocationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_usage(self, resource_group): + response = self.client.location.list_usage( + location="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_cached_images(self, resource_group): + response = self.client.location.list_cached_images( + location="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_capabilities(self, resource_group): + response = self.client.location.list_capabilities( + location="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_location_operations_async.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_location_operations_async.py new file mode 100644 index 000000000000..75c2b0fcd539 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_location_operations_async.py @@ -0,0 +1,53 @@ +# 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.containerinstance.aio import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementLocationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_usage(self, resource_group): + response = self.client.location.list_usage( + location="str", + api_version="2024-10-01-preview", + ) + 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_cached_images(self, resource_group): + response = self.client.location.list_cached_images( + location="str", + api_version="2024-10-01-preview", + ) + 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_capabilities(self, resource_group): + response = self.client.location.list_capabilities( + location="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_operations.py new file mode 100644 index 000000000000..a143119e1b29 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_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.containerinstance import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_operations_async.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_operations_async.py new file mode 100644 index 000000000000..a97e1e109017 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_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.containerinstance.aio import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient, 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-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_subnet_service_association_link_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_subnet_service_association_link_operations.py new file mode 100644 index 000000000000..e15084540596 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_subnet_service_association_link_operations.py @@ -0,0 +1,32 @@ +# 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.containerinstance import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementSubnetServiceAssociationLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.subnet_service_association_link.begin_delete( + resource_group_name=resource_group.name, + virtual_network_name="str", + subnet_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_subnet_service_association_link_operations_async.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_subnet_service_association_link_operations_async.py new file mode 100644 index 000000000000..cdb64304f5dd --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_subnet_service_association_link_operations_async.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 pytest +from azure.mgmt.containerinstance.aio import ContainerInstanceManagementClient + +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 TestContainerInstanceManagementSubnetServiceAssociationLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.subnet_service_association_link.begin_delete( + resource_group_name=resource_group.name, + virtual_network_name="str", + subnet_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/setup.py b/sdk/containerinstance/azure-mgmt-containerinstance/setup.py index b2e316db17b0..ada7b011808e 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/setup.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,68 @@ PACKAGE_PPRINT_NAME = "Container Instance" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'License :: OSI Approved :: MIT License', + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", )