diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/README.md b/sdk/containerinstance/azure-mgmt-containerinstance/README.md index 6508a33173eb2..05cdd4ccefa76 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 181a9b402e2f1..5f3273caee931 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json +++ b/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e716082ac474f182e2220e4f38f1d6191e7636cf", + "commit": "703d4ff3b3c148c528ac780a3c23dd914f515cd8", "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 9db2778257572..79ddd479831a0 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 @@ -27,17 +26,15 @@ class ContainerInstanceManagementClientConfiguration(Configuration): # pylint: :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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-05-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-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-containerinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/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 ca0c4620cbbd1..b3dceda732e2b 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,14 +8,19 @@ 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 from ._serialization import Deserializer, Serializer from .operations import ( + ContainerGroupProfileOperations, + ContainerGroupProfilesOperations, ContainerGroupsOperations, ContainersOperations, LocationOperations, @@ -28,7 +33,7 @@ from azure.core.credentials import TokenCredential -class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerInstanceManagementClient. :ivar container_groups: ContainerGroupsOperations operations @@ -42,15 +47,20 @@ class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-v :ivar subnet_service_association_link: SubnetServiceAssociationLinkOperations operations :vartype subnet_service_association_link: azure.mgmt.containerinstance.operations.SubnetServiceAssociationLinkOperations + :ivar container_group_profiles: ContainerGroupProfilesOperations operations + :vartype container_group_profiles: + azure.mgmt.containerinstance.operations.ContainerGroupProfilesOperations + :ivar container_group_profile: ContainerGroupProfileOperations operations + :vartype container_group_profile: + azure.mgmt.containerinstance.operations.ContainerGroupProfileOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-05-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 +76,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) @@ -81,8 +109,14 @@ def __init__( self.subnet_service_association_link = SubnetServiceAssociationLinkOperations( self._client, self._config, self._serialize, self._deserialize ) + self.container_group_profiles = ContainerGroupProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.container_group_profile = ContainerGroupProfileOperations( + 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 +136,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 f99e77fef9861..17dbc073e01b9 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 842ae727fbbce..8139854b97bb8 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 bd0df84f5319f..0000000000000 --- 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 c1257f7f4e111..e5754a47ce68f 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 4492d81e388ac..fb8c3202e245b 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 @@ -27,17 +26,15 @@ class ContainerInstanceManagementClientConfiguration(Configuration): # pylint: :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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-05-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-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-containerinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/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 6f207cbe5d894..da75152b0ce75 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,14 +8,19 @@ 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 from ._configuration import ContainerInstanceManagementClientConfiguration from .operations import ( + ContainerGroupProfileOperations, + ContainerGroupProfilesOperations, ContainerGroupsOperations, ContainersOperations, LocationOperations, @@ -28,7 +33,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerInstanceManagementClient. :ivar container_groups: ContainerGroupsOperations operations @@ -43,15 +48,20 @@ class ContainerInstanceManagementClient: # pylint: disable=client-accepts-api-v :ivar subnet_service_association_link: SubnetServiceAssociationLinkOperations operations :vartype subnet_service_association_link: azure.mgmt.containerinstance.aio.operations.SubnetServiceAssociationLinkOperations + :ivar container_group_profiles: ContainerGroupProfilesOperations operations + :vartype container_group_profiles: + azure.mgmt.containerinstance.aio.operations.ContainerGroupProfilesOperations + :ivar container_group_profile: ContainerGroupProfileOperations operations + :vartype container_group_profile: + azure.mgmt.containerinstance.aio.operations.ContainerGroupProfileOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-05-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 +77,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) @@ -82,8 +110,16 @@ def __init__( self.subnet_service_association_link = SubnetServiceAssociationLinkOperations( self._client, self._config, self._serialize, self._deserialize ) + self.container_group_profiles = ContainerGroupProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.container_group_profile = ContainerGroupProfileOperations( + 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 +139,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "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 f99e77fef9861..17dbc073e01b9 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/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/__init__.py index 3713b3b709fda..7120d9b773f90 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/__init__.py @@ -11,6 +11,8 @@ from ._location_operations import LocationOperations from ._containers_operations import ContainersOperations from ._subnet_service_association_link_operations import SubnetServiceAssociationLinkOperations +from ._container_group_profiles_operations import ContainerGroupProfilesOperations +from ._container_group_profile_operations import ContainerGroupProfileOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -22,6 +24,8 @@ "LocationOperations", "ContainersOperations", "SubnetServiceAssociationLinkOperations", + "ContainerGroupProfilesOperations", + "ContainerGroupProfileOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_group_profile_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_group_profile_operations.py new file mode 100644 index 0000000000000..793cb6c081825 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_group_profile_operations.py @@ -0,0 +1,216 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._container_group_profile_operations import ( + build_get_by_revision_number_request, + build_list_all_revisions_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ContainerGroupProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.aio.ContainerInstanceManagementClient`'s + :attr:`container_group_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_all_revisions( + self, resource_group_name: str, container_group_profile_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ContainerGroupProfile"]: + """Get a list of all the revisions of the specified container group profile in the given + subscription and resource group. + + Get a list of all the revisions of the specified container group profile in the given + subscription and resource group. This operation returns properties of each revision of the + specified container group profile including containers, image registry credentials, restart + policy, IP address type, OS type volumes, revision number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :return: An iterator like instance of either ContainerGroupProfile or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _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[_models.ContainerGroupProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_all_revisions_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerGroupProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_by_revision_number( + self, resource_group_name: str, container_group_profile_name: str, revision_number: str, **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Get the properties of the specified revision of the container group profile. + + Gets the properties of the specified revision of the container group profile in the given + subscription and resource group. The operation returns the properties of container group + profile including containers, image registry credentials, restart policy, IP address type, OS + type, volumes, current revision number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param revision_number: The revision number of the container group profile. Required. + :type revision_number: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ContainerGroupProfile] = kwargs.pop("cls", None) + + _request = build_get_by_revision_number_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + revision_number=revision_number, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_group_profiles_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_group_profiles_operations.py new file mode 100644 index 0000000000000..3771af4153614 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_group_profiles_operations.py @@ -0,0 +1,625 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._container_group_profiles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_patch_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ContainerGroupProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.aio.ContainerInstanceManagementClient`'s + :attr:`container_group_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.ContainerGroupProfile"]: + """Get a list of container group profiles in the specified subscription. + + Get a list of container group profiles in the specified subscription. This operation returns + properties of each container group profile including containers, image registry credentials, + restart policy, IP address type, OS type,volumes,current revision number, etc. + + :return: An iterator like instance of either ContainerGroupProfile or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _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[_models.ContainerGroupProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerGroupProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ContainerGroupProfile"]: + """Get a list of container group profiles in the specified subscription and resource group. + + Get a list of container group profiles in a specified subscription and resource group. This + operation returns properties of each container group profile including containers, image + registry credentials, restart policy, IP address type, OS type volumes, current revision + number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ContainerGroupProfile or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _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[_models.ContainerGroupProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerGroupProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, container_group_profile_name: str, **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Get the properties of the specified container group profile. + + Gets the properties of the specified container group profile in the specified subscription and + resource group. The operation returns the properties of container group profile including + containers, image registry credentials, restart policy, IP address type, OS type, volumes, + current revision number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ContainerGroupProfile] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + container_group_profile_name: str, + container_group_profile: _models.ContainerGroupProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Create or update container group profiles. + + Create or update container group profiles with specified configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param container_group_profile: The properties of the container group profile to be created or + updated. Required. + :type container_group_profile: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + container_group_profile_name: str, + container_group_profile: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Create or update container group profiles. + + Create or update container group profiles with specified configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param container_group_profile: The properties of the container group profile to be created or + updated. Required. + :type container_group_profile: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + container_group_profile_name: str, + container_group_profile: Union[_models.ContainerGroupProfile, IO[bytes]], + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Create or update container group profiles. + + Create or update container group profiles with specified configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param container_group_profile: The properties of the container group profile to be created or + updated. Is either a ContainerGroupProfile type or a IO[bytes] type. Required. + :type container_group_profile: ~azure.mgmt.containerinstance.models.ContainerGroupProfile or + IO[bytes] + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: 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.ContainerGroupProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container_group_profile, (IOBase, bytes)): + _content = container_group_profile + else: + _json = self._serialize.body(container_group_profile, "ContainerGroupProfile") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def patch( + self, + resource_group_name: str, + container_group_profile_name: str, + properties: _models.ContainerGroupProfilePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Patch container group profiles. + + Patches container group profile with specified properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param properties: The container group profile properties that need to be updated. Required. + :type properties: ~azure.mgmt.containerinstance.models.ContainerGroupProfilePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + container_group_profile_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Patch container group profiles. + + Patches container group profile with specified properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param properties: The container group profile properties that need to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + container_group_profile_name: str, + properties: Union[_models.ContainerGroupProfilePatch, IO[bytes]], + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Patch container group profiles. + + Patches container group profile with specified properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param properties: The container group profile properties that need to be updated. Is either a + ContainerGroupProfilePatch type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.containerinstance.models.ContainerGroupProfilePatch or IO[bytes] + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: 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.ContainerGroupProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ContainerGroupProfilePatch") + + _request = build_patch_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, container_group_profile_name: str, **kwargs: Any + ) -> None: + """Delete the specified container group profile. + + Delete the specified container group profile in the specified subscription and resource group. + The operation does not delete other resources provided by the user, such as volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore 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 a9624d642e4c0..a8badbbc07b9f 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 @@ -161,9 +175,9 @@ def list_by_resource_group( returns properties of each container group including containers, image registry credentials, restart policy, IP address type, OS type, state, and volumes. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContainerGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroup] @@ -175,7 +189,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 +200,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 +219,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 +234,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -239,10 +250,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. @@ -251,16 +258,16 @@ async def get(self, resource_group_name: str, container_group_name: str, **kwarg group. The operation returns the properties of each container group including containers, image registry credentials, restart policy, IP address type, OS type, state, and volumes. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +281,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 +302,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 +329,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 +347,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, @@ -393,7 +389,8 @@ async def begin_create_or_update( Create or update container groups with specified configurations. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -403,14 +400,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 +411,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 @@ -431,24 +420,17 @@ async def begin_create_or_update( Create or update container groups with specified configurations. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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. 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,31 +442,21 @@ 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. Create or update container groups with specified configurations. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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 +483,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 +499,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( @@ -552,7 +523,8 @@ async def update( Updates container group tags with specified values. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -561,7 +533,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 +543,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 @@ -581,16 +552,16 @@ async def update( Updates container group tags with specified values. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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,28 +569,29 @@ 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. Updates container group tags with specified values. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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 +609,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 +622,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 +638,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 +660,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( @@ -741,18 +704,11 @@ async def begin_delete( Delete the specified container group in the specified subscription and resource group. The operation does not delete other resources provided by the user, such as volumes. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +732,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 +748,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 +773,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( @@ -859,18 +817,11 @@ async def begin_restart( Restarts all containers in a container group in place. If container image has updates, new image will be downloaded. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +835,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 +844,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 +858,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 @@ -927,16 +875,16 @@ async def stop( # pylint: disable=inconsistent-return-statements Stops all containers in a container group. Compute resources will be deallocated and billing will stop. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +898,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 +920,12 @@ async 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 - 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 +937,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( @@ -1036,18 +981,11 @@ async def begin_start( Starts all containers in a container group. Compute resources will be allocated and billing will start. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +999,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 +1008,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 +1022,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 @@ -1104,16 +1039,16 @@ async def get_outbound_network_dependencies_endpoints( # pylint: disable=name-t Gets all the network dependencies for this container group to allow complete control of network setting and configuration. For container groups, this will always be an empty list. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +1062,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 +1083,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 da3d40ac11c69..4c510109dab96 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]] @@ -69,7 +73,8 @@ async def list_logs( Get the logs for a specified container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -81,12 +86,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 +104,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 +112,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 +128,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( @@ -153,7 +151,8 @@ async def execute_command( Executes a command for a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -164,7 +163,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 +174,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 @@ -186,18 +184,18 @@ async def execute_command( Executes a command for a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str :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 +207,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. @@ -217,24 +215,22 @@ async def execute_command( Executes a command for a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str :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 +248,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 +262,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 +278,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( @@ -304,18 +294,18 @@ async def attach( Attach to the output stream of a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :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 +319,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 +341,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 8d9e6d6004dad..ebaa9dbe3b5ac 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]] @@ -60,9 +63,8 @@ def __init__(self, *args, **kwargs) -> None: def list_usage(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Get the usage for a subscription. - :param location: The identifier for the physical azure location. Required. + :param location: The name of the Azure region. 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,19 +136,14 @@ 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. Get the list of cached images on specific OS type for a subscription in a region. - :param location: The identifier for the physical azure location. Required. + :param location: The name of the Azure region. 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,19 +216,14 @@ 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. Get the list of CPU/memory/GPU capabilities of a region. - :param location: The identifier for the physical azure location. Required. + :param location: The name of the Azure region. 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 c67943795cd15..ea2cd970a8d26 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 c113aac2d8f0c..9cd84db966f17 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( @@ -109,20 +117,13 @@ async def begin_delete( Delete container group virtual network association links. The operation does not delete other resources provided by the user. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param virtual_network_name: The name of the virtual network. Required. :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 +137,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 +147,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 +161,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 13597377f7bf1..a9551a9b83d25 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 @@ -14,6 +14,7 @@ from ._models_py3 import CapabilitiesListResult from ._models_py3 import CloudErrorBody from ._models_py3 import ConfidentialComputeProperties +from ._models_py3 import ConfigMap from ._models_py3 import Container from ._models_py3 import ContainerAttachResponse from ._models_py3 import ContainerExec @@ -24,6 +25,11 @@ from ._models_py3 import ContainerGroupDiagnostics from ._models_py3 import ContainerGroupIdentity from ._models_py3 import ContainerGroupListResult +from ._models_py3 import ContainerGroupProfile +from ._models_py3 import ContainerGroupProfileListResult +from ._models_py3 import ContainerGroupProfilePatch +from ._models_py3 import ContainerGroupProfileProperties +from ._models_py3 import ContainerGroupProfileReferenceDefinition from ._models_py3 import ContainerGroupProperties from ._models_py3 import ContainerGroupPropertiesInstanceView from ._models_py3 import ContainerGroupSubnetId @@ -56,6 +62,7 @@ from ._models_py3 import ResourceRequirements from ._models_py3 import SecurityContextCapabilitiesDefinition from ._models_py3 import SecurityContextDefinition +from ._models_py3 import StandbyPoolProfileDefinition from ._models_py3 import Usage from ._models_py3 import UsageListResult from ._models_py3 import UsageName @@ -89,6 +96,7 @@ "CapabilitiesListResult", "CloudErrorBody", "ConfidentialComputeProperties", + "ConfigMap", "Container", "ContainerAttachResponse", "ContainerExec", @@ -99,6 +107,11 @@ "ContainerGroupDiagnostics", "ContainerGroupIdentity", "ContainerGroupListResult", + "ContainerGroupProfile", + "ContainerGroupProfileListResult", + "ContainerGroupProfilePatch", + "ContainerGroupProfileProperties", + "ContainerGroupProfileReferenceDefinition", "ContainerGroupProperties", "ContainerGroupPropertiesInstanceView", "ContainerGroupSubnetId", @@ -131,6 +144,7 @@ "ResourceRequirements", "SecurityContextCapabilitiesDefinition", "SecurityContextDefinition", + "StandbyPoolProfileDefinition", "Usage", "UsageListResult", "UsageName", 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 ddc9e922ab730..6deb8bee8d246 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 @@ -84,7 +84,7 @@ def __init__( 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 @@ -323,16 +323,36 @@ def __init__(self, *, cce_policy: Optional[str] = None, **kwargs: Any) -> None: self.cce_policy = cce_policy +class ConfigMap(_serialization.Model): + """The container config map. + + :ivar key_value_pairs: The key value pairs dictionary in the config map. + :vartype key_value_pairs: dict[str, str] + """ + + _attribute_map = { + "key_value_pairs": {"key": "keyValuePairs", "type": "{str}"}, + } + + def __init__(self, *, key_value_pairs: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword key_value_pairs: The key value pairs dictionary in the config map. + :paramtype key_value_pairs: dict[str, str] + """ + super().__init__(**kwargs) + self.key_value_pairs = key_value_pairs + + class Container(_serialization.Model): # pylint: disable=too-many-instance-attributes """A container instance. 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 - :ivar image: The name of the image used to create the container instance. Required. + :ivar image: The name of the image used to create the container instance. :vartype image: str :ivar command: The commands to execute within the container instance in exec form. :vartype command: list[str] @@ -342,7 +362,7 @@ class Container(_serialization.Model): # pylint: disable=too-many-instance-attr :vartype environment_variables: list[~azure.mgmt.containerinstance.models.EnvironmentVariable] :ivar instance_view: The instance view of the container instance. Only valid in response. :vartype instance_view: ~azure.mgmt.containerinstance.models.ContainerPropertiesInstanceView - :ivar resources: The resource requirements of the container instance. Required. + :ivar resources: The resource requirements of the container instance. :vartype resources: ~azure.mgmt.containerinstance.models.ResourceRequirements :ivar volume_mounts: The volume mounts available to the container instance. :vartype volume_mounts: list[~azure.mgmt.containerinstance.models.VolumeMount] @@ -352,13 +372,13 @@ class Container(_serialization.Model): # pylint: disable=too-many-instance-attr :vartype readiness_probe: ~azure.mgmt.containerinstance.models.ContainerProbe :ivar security_context: The container security properties. :vartype security_context: ~azure.mgmt.containerinstance.models.SecurityContextDefinition + :ivar config_map: The config map. + :vartype config_map: ~azure.mgmt.containerinstance.models.ConfigMap """ _validation = { "name": {"required": True}, - "image": {"required": True}, "instance_view": {"readonly": True}, - "resources": {"required": True}, } _attribute_map = { @@ -373,27 +393,29 @@ class Container(_serialization.Model): # pylint: disable=too-many-instance-attr "liveness_probe": {"key": "properties.livenessProbe", "type": "ContainerProbe"}, "readiness_probe": {"key": "properties.readinessProbe", "type": "ContainerProbe"}, "security_context": {"key": "properties.securityContext", "type": "SecurityContextDefinition"}, + "config_map": {"key": "properties.configMap", "type": "ConfigMap"}, } def __init__( self, *, name: str, - image: str, - resources: "_models.ResourceRequirements", + image: Optional[str] = None, command: Optional[List[str]] = None, ports: Optional[List["_models.ContainerPort"]] = None, environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, + resources: Optional["_models.ResourceRequirements"] = None, volume_mounts: Optional[List["_models.VolumeMount"]] = None, liveness_probe: Optional["_models.ContainerProbe"] = None, readiness_probe: Optional["_models.ContainerProbe"] = None, security_context: Optional["_models.SecurityContextDefinition"] = None, + config_map: Optional["_models.ConfigMap"] = None, **kwargs: Any ) -> None: """ :keyword name: The user-provided name of the container instance. Required. :paramtype name: str - :keyword image: The name of the image used to create the container instance. Required. + :keyword image: The name of the image used to create the container instance. :paramtype image: str :keyword command: The commands to execute within the container instance in exec form. :paramtype command: list[str] @@ -402,7 +424,7 @@ def __init__( :keyword environment_variables: The environment variables to set in the container instance. :paramtype environment_variables: list[~azure.mgmt.containerinstance.models.EnvironmentVariable] - :keyword resources: The resource requirements of the container instance. Required. + :keyword resources: The resource requirements of the container instance. :paramtype resources: ~azure.mgmt.containerinstance.models.ResourceRequirements :keyword volume_mounts: The volume mounts available to the container instance. :paramtype volume_mounts: list[~azure.mgmt.containerinstance.models.VolumeMount] @@ -412,6 +434,8 @@ def __init__( :paramtype readiness_probe: ~azure.mgmt.containerinstance.models.ContainerProbe :keyword security_context: The container security properties. :paramtype security_context: ~azure.mgmt.containerinstance.models.SecurityContextDefinition + :keyword config_map: The config map. + :paramtype config_map: ~azure.mgmt.containerinstance.models.ConfigMap """ super().__init__(**kwargs) self.name = name @@ -425,6 +449,7 @@ def __init__( self.liveness_probe = liveness_probe self.readiness_probe = readiness_probe self.security_context = security_context + self.config_map = config_map class ContainerAttachResponse(_serialization.Model): @@ -564,7 +589,7 @@ 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 @@ -588,7 +613,7 @@ class ContainerGroupProperties(_serialization.Model): # pylint: disable=too-man :ivar ip_address: The IP address type of the container group. :vartype ip_address: ~azure.mgmt.containerinstance.models.IpAddress :ivar os_type: The operating system type required by the containers in the container group. - Required. Known values are: "Windows" and "Linux". + Known values are: "Windows" and "Linux". :vartype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes :ivar volumes: The list of volumes that can be mounted by containers in this container group. :vartype volumes: list[~azure.mgmt.containerinstance.models.Volume] @@ -615,13 +640,22 @@ class ContainerGroupProperties(_serialization.Model): # pylint: disable=too-man ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties :ivar priority: The priority of the container group. Known values are: "Regular" and "Spot". :vartype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + :ivar container_group_profile: The reference container group profile properties. + :vartype container_group_profile: + ~azure.mgmt.containerinstance.models.ContainerGroupProfileReferenceDefinition + :ivar standby_pool_profile: The reference standby pool profile properties. + :vartype standby_pool_profile: + ~azure.mgmt.containerinstance.models.StandbyPoolProfileDefinition + :ivar is_created_from_standby_pool: The flag indicating whether the container group is created + by standby pool. + :vartype is_created_from_standby_pool: bool """ _validation = { "provisioning_state": {"readonly": True}, "containers": {"required": True}, - "os_type": {"required": True}, "instance_view": {"readonly": True}, + "is_created_from_standby_pool": {"readonly": True}, } _attribute_map = { @@ -649,17 +683,23 @@ class ContainerGroupProperties(_serialization.Model): # pylint: disable=too-man "type": "ConfidentialComputeProperties", }, "priority": {"key": "properties.priority", "type": "str"}, + "container_group_profile": { + "key": "properties.containerGroupProfile", + "type": "ContainerGroupProfileReferenceDefinition", + }, + "standby_pool_profile": {"key": "properties.standbyPoolProfile", "type": "StandbyPoolProfileDefinition"}, + "is_created_from_standby_pool": {"key": "properties.isCreatedFromStandbyPool", "type": "bool"}, } def __init__( self, *, containers: List["_models.Container"], - os_type: Union[str, "_models.OperatingSystemTypes"], identity: Optional["_models.ContainerGroupIdentity"] = None, image_registry_credentials: Optional[List["_models.ImageRegistryCredential"]] = None, restart_policy: Optional[Union[str, "_models.ContainerGroupRestartPolicy"]] = None, ip_address: Optional["_models.IpAddress"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, volumes: Optional[List["_models.Volume"]] = None, diagnostics: Optional["_models.ContainerGroupDiagnostics"] = None, subnet_ids: Optional[List["_models.ContainerGroupSubnetId"]] = None, @@ -670,6 +710,8 @@ def __init__( extensions: Optional[List["_models.DeploymentExtensionSpec"]] = None, confidential_compute_properties: Optional["_models.ConfidentialComputeProperties"] = None, priority: Optional[Union[str, "_models.ContainerGroupPriority"]] = None, + container_group_profile: Optional["_models.ContainerGroupProfileReferenceDefinition"] = None, + standby_pool_profile: Optional["_models.StandbyPoolProfileDefinition"] = None, **kwargs: Any ) -> None: """ @@ -692,7 +734,7 @@ def __init__( :keyword ip_address: The IP address type of the container group. :paramtype ip_address: ~azure.mgmt.containerinstance.models.IpAddress :keyword os_type: The operating system type required by the containers in the container group. - Required. Known values are: "Windows" and "Linux". + Known values are: "Windows" and "Linux". :paramtype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes :keyword volumes: The list of volumes that can be mounted by containers in this container group. @@ -717,6 +759,12 @@ def __init__( ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties :keyword priority: The priority of the container group. Known values are: "Regular" and "Spot". :paramtype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + :keyword container_group_profile: The reference container group profile properties. + :paramtype container_group_profile: + ~azure.mgmt.containerinstance.models.ContainerGroupProfileReferenceDefinition + :keyword standby_pool_profile: The reference standby pool profile properties. + :paramtype standby_pool_profile: + ~azure.mgmt.containerinstance.models.StandbyPoolProfileDefinition """ super().__init__(**kwargs) self.identity = identity @@ -737,6 +785,9 @@ def __init__( self.extensions = extensions self.confidential_compute_properties = confidential_compute_properties self.priority = priority + self.container_group_profile = container_group_profile + self.standby_pool_profile = standby_pool_profile + self.is_created_from_standby_pool = None class Resource(_serialization.Model): @@ -803,7 +854,7 @@ 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 @@ -827,7 +878,7 @@ class ContainerGroup(Resource, ContainerGroupProperties): # pylint: disable=too :ivar ip_address: The IP address type of the container group. :vartype ip_address: ~azure.mgmt.containerinstance.models.IpAddress :ivar os_type: The operating system type required by the containers in the container group. - Required. Known values are: "Windows" and "Linux". + Known values are: "Windows" and "Linux". :vartype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes :ivar volumes: The list of volumes that can be mounted by containers in this container group. :vartype volumes: list[~azure.mgmt.containerinstance.models.Volume] @@ -854,6 +905,15 @@ class ContainerGroup(Resource, ContainerGroupProperties): # pylint: disable=too ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties :ivar priority: The priority of the container group. Known values are: "Regular" and "Spot". :vartype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + :ivar container_group_profile: The reference container group profile properties. + :vartype container_group_profile: + ~azure.mgmt.containerinstance.models.ContainerGroupProfileReferenceDefinition + :ivar standby_pool_profile: The reference standby pool profile properties. + :vartype standby_pool_profile: + ~azure.mgmt.containerinstance.models.StandbyPoolProfileDefinition + :ivar is_created_from_standby_pool: The flag indicating whether the container group is created + by standby pool. + :vartype is_created_from_standby_pool: bool :ivar id: The resource id. :vartype id: str :ivar name: The resource name. @@ -871,8 +931,8 @@ class ContainerGroup(Resource, ContainerGroupProperties): # pylint: disable=too _validation = { "provisioning_state": {"readonly": True}, "containers": {"required": True}, - "os_type": {"required": True}, "instance_view": {"readonly": True}, + "is_created_from_standby_pool": {"readonly": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -903,6 +963,12 @@ class ContainerGroup(Resource, ContainerGroupProperties): # pylint: disable=too "type": "ConfidentialComputeProperties", }, "priority": {"key": "properties.priority", "type": "str"}, + "container_group_profile": { + "key": "properties.containerGroupProfile", + "type": "ContainerGroupProfileReferenceDefinition", + }, + "standby_pool_profile": {"key": "properties.standbyPoolProfile", "type": "StandbyPoolProfileDefinition"}, + "is_created_from_standby_pool": {"key": "properties.isCreatedFromStandbyPool", "type": "bool"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, @@ -915,11 +981,11 @@ def __init__( # pylint: disable=too-many-locals self, *, containers: List["_models.Container"], - os_type: Union[str, "_models.OperatingSystemTypes"], identity: Optional["_models.ContainerGroupIdentity"] = None, image_registry_credentials: Optional[List["_models.ImageRegistryCredential"]] = None, restart_policy: Optional[Union[str, "_models.ContainerGroupRestartPolicy"]] = None, ip_address: Optional["_models.IpAddress"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, volumes: Optional[List["_models.Volume"]] = None, diagnostics: Optional["_models.ContainerGroupDiagnostics"] = None, subnet_ids: Optional[List["_models.ContainerGroupSubnetId"]] = None, @@ -930,6 +996,8 @@ def __init__( # pylint: disable=too-many-locals extensions: Optional[List["_models.DeploymentExtensionSpec"]] = None, confidential_compute_properties: Optional["_models.ConfidentialComputeProperties"] = None, priority: Optional[Union[str, "_models.ContainerGroupPriority"]] = None, + container_group_profile: Optional["_models.ContainerGroupProfileReferenceDefinition"] = None, + standby_pool_profile: Optional["_models.StandbyPoolProfileDefinition"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, @@ -955,7 +1023,7 @@ def __init__( # pylint: disable=too-many-locals :keyword ip_address: The IP address type of the container group. :paramtype ip_address: ~azure.mgmt.containerinstance.models.IpAddress :keyword os_type: The operating system type required by the containers in the container group. - Required. Known values are: "Windows" and "Linux". + Known values are: "Windows" and "Linux". :paramtype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes :keyword volumes: The list of volumes that can be mounted by containers in this container group. @@ -980,6 +1048,12 @@ def __init__( # pylint: disable=too-many-locals ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties :keyword priority: The priority of the container group. Known values are: "Regular" and "Spot". :paramtype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + :keyword container_group_profile: The reference container group profile properties. + :paramtype container_group_profile: + ~azure.mgmt.containerinstance.models.ContainerGroupProfileReferenceDefinition + :keyword standby_pool_profile: The reference standby pool profile properties. + :paramtype standby_pool_profile: + ~azure.mgmt.containerinstance.models.StandbyPoolProfileDefinition :keyword location: The resource location. :paramtype location: str :keyword tags: The resource tags. @@ -1007,6 +1081,8 @@ def __init__( # pylint: disable=too-many-locals extensions=extensions, confidential_compute_properties=confidential_compute_properties, priority=priority, + container_group_profile=container_group_profile, + standby_pool_profile=standby_pool_profile, **kwargs ) self.identity = identity @@ -1027,6 +1103,9 @@ def __init__( # pylint: disable=too-many-locals self.extensions = extensions self.confidential_compute_properties = confidential_compute_properties self.priority = priority + self.container_group_profile = container_group_profile + self.standby_pool_profile = standby_pool_profile + self.is_created_from_standby_pool = None self.id = None self.name = None self.type = None @@ -1142,6 +1221,453 @@ def __init__( self.next_link = next_link +class ContainerGroupProfileProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The container group profile properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :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 + is created from. + :vartype image_registry_credentials: + list[~azure.mgmt.containerinstance.models.ImageRegistryCredential] + :ivar restart_policy: Restart policy for all containers within the container group. + + + * ``Always`` Always restart + * ``OnFailure`` Restart on failure + * ``Never`` Never restart. Known values are: "Always", "OnFailure", and "Never". + :vartype restart_policy: str or + ~azure.mgmt.containerinstance.models.ContainerGroupRestartPolicy + :ivar ip_address: The IP address type of the container group. + :vartype ip_address: ~azure.mgmt.containerinstance.models.IpAddress + :ivar os_type: The operating system type required by the containers in the container group. + Required. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes + :ivar volumes: The list of volumes that can be mounted by containers in this container group. + :vartype volumes: list[~azure.mgmt.containerinstance.models.Volume] + :ivar diagnostics: The diagnostic information for a container group. + :vartype diagnostics: ~azure.mgmt.containerinstance.models.ContainerGroupDiagnostics + :ivar sku: The SKU for a container group. Known values are: "Standard", "Dedicated", and + "Confidential". + :vartype sku: str or ~azure.mgmt.containerinstance.models.ContainerGroupSku + :ivar encryption_properties: The encryption properties for a container group. + :vartype encryption_properties: ~azure.mgmt.containerinstance.models.EncryptionProperties + :ivar init_containers: The init containers for a container group. + :vartype init_containers: list[~azure.mgmt.containerinstance.models.InitContainerDefinition] + :ivar extensions: extensions used by virtual kubelet. + :vartype extensions: list[~azure.mgmt.containerinstance.models.DeploymentExtensionSpec] + :ivar confidential_compute_properties: The properties for confidential container group. + :vartype confidential_compute_properties: + ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties + :ivar priority: The priority of the container group. Known values are: "Regular" and "Spot". + :vartype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + :ivar revision: The container group profile current revision number. This only appears in the + response. + :vartype revision: int + """ + + _validation = { + "containers": {"required": True}, + "os_type": {"required": True}, + "revision": {"readonly": True}, + } + + _attribute_map = { + "containers": {"key": "properties.containers", "type": "[Container]"}, + "image_registry_credentials": { + "key": "properties.imageRegistryCredentials", + "type": "[ImageRegistryCredential]", + }, + "restart_policy": {"key": "properties.restartPolicy", "type": "str"}, + "ip_address": {"key": "properties.ipAddress", "type": "IpAddress"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "volumes": {"key": "properties.volumes", "type": "[Volume]"}, + "diagnostics": {"key": "properties.diagnostics", "type": "ContainerGroupDiagnostics"}, + "sku": {"key": "properties.sku", "type": "str"}, + "encryption_properties": {"key": "properties.encryptionProperties", "type": "EncryptionProperties"}, + "init_containers": {"key": "properties.initContainers", "type": "[InitContainerDefinition]"}, + "extensions": {"key": "properties.extensions", "type": "[DeploymentExtensionSpec]"}, + "confidential_compute_properties": { + "key": "properties.confidentialComputeProperties", + "type": "ConfidentialComputeProperties", + }, + "priority": {"key": "properties.priority", "type": "str"}, + "revision": {"key": "properties.revision", "type": "int"}, + } + + def __init__( + self, + *, + containers: List["_models.Container"], + os_type: Union[str, "_models.OperatingSystemTypes"], + image_registry_credentials: Optional[List["_models.ImageRegistryCredential"]] = None, + restart_policy: Optional[Union[str, "_models.ContainerGroupRestartPolicy"]] = None, + ip_address: Optional["_models.IpAddress"] = None, + volumes: Optional[List["_models.Volume"]] = None, + diagnostics: Optional["_models.ContainerGroupDiagnostics"] = None, + sku: Optional[Union[str, "_models.ContainerGroupSku"]] = None, + encryption_properties: Optional["_models.EncryptionProperties"] = None, + init_containers: Optional[List["_models.InitContainerDefinition"]] = None, + extensions: Optional[List["_models.DeploymentExtensionSpec"]] = None, + confidential_compute_properties: Optional["_models.ConfidentialComputeProperties"] = None, + priority: Optional[Union[str, "_models.ContainerGroupPriority"]] = None, + **kwargs: Any + ) -> None: + """ + :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 + group is created from. + :paramtype image_registry_credentials: + list[~azure.mgmt.containerinstance.models.ImageRegistryCredential] + :keyword restart_policy: Restart policy for all containers within the container group. + + + * ``Always`` Always restart + * ``OnFailure`` Restart on failure + * ``Never`` Never restart. Known values are: "Always", "OnFailure", and "Never". + :paramtype restart_policy: str or + ~azure.mgmt.containerinstance.models.ContainerGroupRestartPolicy + :keyword ip_address: The IP address type of the container group. + :paramtype ip_address: ~azure.mgmt.containerinstance.models.IpAddress + :keyword os_type: The operating system type required by the containers in the container group. + Required. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes + :keyword volumes: The list of volumes that can be mounted by containers in this container + group. + :paramtype volumes: list[~azure.mgmt.containerinstance.models.Volume] + :keyword diagnostics: The diagnostic information for a container group. + :paramtype diagnostics: ~azure.mgmt.containerinstance.models.ContainerGroupDiagnostics + :keyword sku: The SKU for a container group. Known values are: "Standard", "Dedicated", and + "Confidential". + :paramtype sku: str or ~azure.mgmt.containerinstance.models.ContainerGroupSku + :keyword encryption_properties: The encryption properties for a container group. + :paramtype encryption_properties: ~azure.mgmt.containerinstance.models.EncryptionProperties + :keyword init_containers: The init containers for a container group. + :paramtype init_containers: list[~azure.mgmt.containerinstance.models.InitContainerDefinition] + :keyword extensions: extensions used by virtual kubelet. + :paramtype extensions: list[~azure.mgmt.containerinstance.models.DeploymentExtensionSpec] + :keyword confidential_compute_properties: The properties for confidential container group. + :paramtype confidential_compute_properties: + ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties + :keyword priority: The priority of the container group. Known values are: "Regular" and "Spot". + :paramtype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + """ + super().__init__(**kwargs) + self.containers = containers + self.image_registry_credentials = image_registry_credentials + self.restart_policy = restart_policy + self.ip_address = ip_address + self.os_type = os_type + self.volumes = volumes + self.diagnostics = diagnostics + self.sku = sku + self.encryption_properties = encryption_properties + self.init_containers = init_containers + self.extensions = extensions + self.confidential_compute_properties = confidential_compute_properties + self.priority = priority + self.revision = None + + +class ContainerGroupProfile(Resource, ContainerGroupProfileProperties): # pylint: disable=too-many-instance-attributes + """A container group profile. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar 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 + is created from. + :vartype image_registry_credentials: + list[~azure.mgmt.containerinstance.models.ImageRegistryCredential] + :ivar restart_policy: Restart policy for all containers within the container group. + + + * ``Always`` Always restart + * ``OnFailure`` Restart on failure + * ``Never`` Never restart. Known values are: "Always", "OnFailure", and "Never". + :vartype restart_policy: str or + ~azure.mgmt.containerinstance.models.ContainerGroupRestartPolicy + :ivar ip_address: The IP address type of the container group. + :vartype ip_address: ~azure.mgmt.containerinstance.models.IpAddress + :ivar os_type: The operating system type required by the containers in the container group. + Required. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes + :ivar volumes: The list of volumes that can be mounted by containers in this container group. + :vartype volumes: list[~azure.mgmt.containerinstance.models.Volume] + :ivar diagnostics: The diagnostic information for a container group. + :vartype diagnostics: ~azure.mgmt.containerinstance.models.ContainerGroupDiagnostics + :ivar sku: The SKU for a container group. Known values are: "Standard", "Dedicated", and + "Confidential". + :vartype sku: str or ~azure.mgmt.containerinstance.models.ContainerGroupSku + :ivar encryption_properties: The encryption properties for a container group. + :vartype encryption_properties: ~azure.mgmt.containerinstance.models.EncryptionProperties + :ivar init_containers: The init containers for a container group. + :vartype init_containers: list[~azure.mgmt.containerinstance.models.InitContainerDefinition] + :ivar extensions: extensions used by virtual kubelet. + :vartype extensions: list[~azure.mgmt.containerinstance.models.DeploymentExtensionSpec] + :ivar confidential_compute_properties: The properties for confidential container group. + :vartype confidential_compute_properties: + ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties + :ivar priority: The priority of the container group. Known values are: "Regular" and "Spot". + :vartype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + :ivar revision: The container group profile current revision number. This only appears in the + response. + :vartype revision: int + :ivar id: The resource id. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar location: The resource location. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + :ivar zones: The zones for the container group. + :vartype zones: list[str] + """ + + _validation = { + "containers": {"required": True}, + "os_type": {"required": True}, + "revision": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "containers": {"key": "properties.containers", "type": "[Container]"}, + "image_registry_credentials": { + "key": "properties.imageRegistryCredentials", + "type": "[ImageRegistryCredential]", + }, + "restart_policy": {"key": "properties.restartPolicy", "type": "str"}, + "ip_address": {"key": "properties.ipAddress", "type": "IpAddress"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "volumes": {"key": "properties.volumes", "type": "[Volume]"}, + "diagnostics": {"key": "properties.diagnostics", "type": "ContainerGroupDiagnostics"}, + "sku": {"key": "properties.sku", "type": "str"}, + "encryption_properties": {"key": "properties.encryptionProperties", "type": "EncryptionProperties"}, + "init_containers": {"key": "properties.initContainers", "type": "[InitContainerDefinition]"}, + "extensions": {"key": "properties.extensions", "type": "[DeploymentExtensionSpec]"}, + "confidential_compute_properties": { + "key": "properties.confidentialComputeProperties", + "type": "ConfidentialComputeProperties", + }, + "priority": {"key": "properties.priority", "type": "str"}, + "revision": {"key": "properties.revision", "type": "int"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "zones": {"key": "zones", "type": "[str]"}, + } + + def __init__( + self, + *, + containers: List["_models.Container"], + os_type: Union[str, "_models.OperatingSystemTypes"], + image_registry_credentials: Optional[List["_models.ImageRegistryCredential"]] = None, + restart_policy: Optional[Union[str, "_models.ContainerGroupRestartPolicy"]] = None, + ip_address: Optional["_models.IpAddress"] = None, + volumes: Optional[List["_models.Volume"]] = None, + diagnostics: Optional["_models.ContainerGroupDiagnostics"] = None, + sku: Optional[Union[str, "_models.ContainerGroupSku"]] = None, + encryption_properties: Optional["_models.EncryptionProperties"] = None, + init_containers: Optional[List["_models.InitContainerDefinition"]] = None, + extensions: Optional[List["_models.DeploymentExtensionSpec"]] = None, + confidential_compute_properties: Optional["_models.ConfidentialComputeProperties"] = None, + priority: Optional[Union[str, "_models.ContainerGroupPriority"]] = None, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + zones: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :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 + group is created from. + :paramtype image_registry_credentials: + list[~azure.mgmt.containerinstance.models.ImageRegistryCredential] + :keyword restart_policy: Restart policy for all containers within the container group. + + + * ``Always`` Always restart + * ``OnFailure`` Restart on failure + * ``Never`` Never restart. Known values are: "Always", "OnFailure", and "Never". + :paramtype restart_policy: str or + ~azure.mgmt.containerinstance.models.ContainerGroupRestartPolicy + :keyword ip_address: The IP address type of the container group. + :paramtype ip_address: ~azure.mgmt.containerinstance.models.IpAddress + :keyword os_type: The operating system type required by the containers in the container group. + Required. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes + :keyword volumes: The list of volumes that can be mounted by containers in this container + group. + :paramtype volumes: list[~azure.mgmt.containerinstance.models.Volume] + :keyword diagnostics: The diagnostic information for a container group. + :paramtype diagnostics: ~azure.mgmt.containerinstance.models.ContainerGroupDiagnostics + :keyword sku: The SKU for a container group. Known values are: "Standard", "Dedicated", and + "Confidential". + :paramtype sku: str or ~azure.mgmt.containerinstance.models.ContainerGroupSku + :keyword encryption_properties: The encryption properties for a container group. + :paramtype encryption_properties: ~azure.mgmt.containerinstance.models.EncryptionProperties + :keyword init_containers: The init containers for a container group. + :paramtype init_containers: list[~azure.mgmt.containerinstance.models.InitContainerDefinition] + :keyword extensions: extensions used by virtual kubelet. + :paramtype extensions: list[~azure.mgmt.containerinstance.models.DeploymentExtensionSpec] + :keyword confidential_compute_properties: The properties for confidential container group. + :paramtype confidential_compute_properties: + ~azure.mgmt.containerinstance.models.ConfidentialComputeProperties + :keyword priority: The priority of the container group. Known values are: "Regular" and "Spot". + :paramtype priority: str or ~azure.mgmt.containerinstance.models.ContainerGroupPriority + :keyword location: The resource location. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + :keyword zones: The zones for the container group. + :paramtype zones: list[str] + """ + super().__init__( + location=location, + tags=tags, + zones=zones, + containers=containers, + image_registry_credentials=image_registry_credentials, + restart_policy=restart_policy, + ip_address=ip_address, + os_type=os_type, + volumes=volumes, + diagnostics=diagnostics, + sku=sku, + encryption_properties=encryption_properties, + init_containers=init_containers, + extensions=extensions, + confidential_compute_properties=confidential_compute_properties, + priority=priority, + **kwargs + ) + self.containers = containers + self.image_registry_credentials = image_registry_credentials + self.restart_policy = restart_policy + self.ip_address = ip_address + self.os_type = os_type + self.volumes = volumes + self.diagnostics = diagnostics + self.sku = sku + self.encryption_properties = encryption_properties + self.init_containers = init_containers + self.extensions = extensions + self.confidential_compute_properties = confidential_compute_properties + self.priority = priority + self.revision = None + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.zones = zones + + +class ContainerGroupProfileListResult(_serialization.Model): + """The container group profile list response that contains the container group profile properties. + + :ivar value: The list of container group profiles. + :vartype value: list[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :ivar next_link: The URI to fetch the next page of container group profiles. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ContainerGroupProfile]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ContainerGroupProfile"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of container group profiles. + :paramtype value: list[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :keyword next_link: The URI to fetch the next page of container group profiles. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ContainerGroupProfilePatch(_serialization.Model): + """Properties of container group profile that need to be patched. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class ContainerGroupProfileReferenceDefinition(_serialization.Model): + """The container group profile reference. + + :ivar id: The container group profile reference id.This will be an ARM resource id in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}'. # pylint: disable=line-too-long + :vartype id: str + :ivar revision: The container group profile reference revision. + :vartype revision: int + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "revision": {"key": "revision", "type": "int"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + revision: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The container group profile reference id.This will be an ARM resource id in the + form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}'. # pylint: disable=line-too-long + :paramtype id: str + :keyword revision: The container group profile reference revision. + :paramtype revision: int + """ + super().__init__(**kwargs) + self.id = id + self.revision = revision + + class ContainerGroupPropertiesInstanceView(_serialization.Model): """The instance view of the container group. Only valid in response. @@ -1173,7 +1699,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 +1733,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 +1785,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 +1968,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 +2027,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 +2072,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 +2120,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 @@ -1682,7 +2208,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 +2252,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 +2312,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. @@ -1849,7 +2375,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 +2445,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 +2488,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 +2573,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 +2655,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 +2783,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 +2860,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 +2901,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 @@ -2499,6 +3025,45 @@ def __init__( self.seccomp_profile = seccomp_profile +class StandbyPoolProfileDefinition(_serialization.Model): + """The standby pool profile reference. + + :ivar id: The standby pool profile reference id.This will be an ARM resource id in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StandbyPool/standbyContainerGroupPools/{standbyPoolName}'. # pylint: disable=line-too-long + :vartype id: str + :ivar fail_container_group_create_on_reuse_failure: The flag to determine whether ACI should + fail the create request if the container group can not be obtained from standby pool. + :vartype fail_container_group_create_on_reuse_failure: bool + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "fail_container_group_create_on_reuse_failure": { + "key": "failContainerGroupCreateOnReuseFailure", + "type": "bool", + }, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + fail_container_group_create_on_reuse_failure: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The standby pool profile reference id.This will be an ARM resource id in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StandbyPool/standbyContainerGroupPools/{standbyPoolName}'. # pylint: disable=line-too-long + :paramtype id: str + :keyword fail_container_group_create_on_reuse_failure: The flag to determine whether ACI should + fail the create request if the container group can not be obtained from standby pool. + :paramtype fail_container_group_create_on_reuse_failure: bool + """ + super().__init__(**kwargs) + self.id = id + self.fail_container_group_create_on_reuse_failure = fail_container_group_create_on_reuse_failure + + class Usage(_serialization.Model): """A single usage result. @@ -2626,7 +3191,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 @@ -2685,7 +3250,7 @@ def __init__( 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/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/__init__.py index 3713b3b709fda..7120d9b773f90 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/__init__.py @@ -11,6 +11,8 @@ from ._location_operations import LocationOperations from ._containers_operations import ContainersOperations from ._subnet_service_association_link_operations import SubnetServiceAssociationLinkOperations +from ._container_group_profiles_operations import ContainerGroupProfilesOperations +from ._container_group_profile_operations import ContainerGroupProfileOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -22,6 +24,8 @@ "LocationOperations", "ContainersOperations", "SubnetServiceAssociationLinkOperations", + "ContainerGroupProfilesOperations", + "ContainerGroupProfileOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_group_profile_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_group_profile_operations.py new file mode 100644 index 0000000000000..ea2f7ca60b951 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_group_profile_operations.py @@ -0,0 +1,300 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.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 + +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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_all_revisions_request( + resource_group_name: str, container_group_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}/revisions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerGroupProfileName": _SERIALIZER.url( + "container_group_profile_name", + container_group_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^(?!.*--)[a-z0-9]([-a-z0-9]*[a-z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_by_revision_number_request( + resource_group_name: str, + container_group_profile_name: str, + revision_number: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}/revisions/{revisionNumber}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerGroupProfileName": _SERIALIZER.url( + "container_group_profile_name", + container_group_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^(?!.*--)[a-z0-9]([-a-z0-9]*[a-z0-9])?$", + ), + "revisionNumber": _SERIALIZER.url("revision_number", revision_number, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerGroupProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.ContainerInstanceManagementClient`'s + :attr:`container_group_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_all_revisions( + self, resource_group_name: str, container_group_profile_name: str, **kwargs: Any + ) -> Iterable["_models.ContainerGroupProfile"]: + """Get a list of all the revisions of the specified container group profile in the given + subscription and resource group. + + Get a list of all the revisions of the specified container group profile in the given + subscription and resource group. This operation returns properties of each revision of the + specified container group profile including containers, image registry credentials, restart + policy, IP address type, OS type volumes, revision number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :return: An iterator like instance of either ContainerGroupProfile or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _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[_models.ContainerGroupProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_all_revisions_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerGroupProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_by_revision_number( + self, resource_group_name: str, container_group_profile_name: str, revision_number: str, **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Get the properties of the specified revision of the container group profile. + + Gets the properties of the specified revision of the container group profile in the given + subscription and resource group. The operation returns the properties of container group + profile including containers, image registry credentials, restart policy, IP address type, OS + type, volumes, current revision number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param revision_number: The revision number of the container group profile. Required. + :type revision_number: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ContainerGroupProfile] = kwargs.pop("cls", None) + + _request = build_get_by_revision_number_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + revision_number=revision_number, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_group_profiles_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_group_profiles_operations.py new file mode 100644 index 0000000000000..a759ea9e9238c --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_group_profiles_operations.py @@ -0,0 +1,842 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.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 + +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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroupProfiles" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, container_group_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerGroupProfileName": _SERIALIZER.url( + "container_group_profile_name", + container_group_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^(?!.*--)[a-z0-9]([-a-z0-9]*[a-z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, container_group_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerGroupProfileName": _SERIALIZER.url( + "container_group_profile_name", + container_group_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^(?!.*--)[a-z0-9]([-a-z0-9]*[a-z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_patch_request( + resource_group_name: str, container_group_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerGroupProfileName": _SERIALIZER.url( + "container_group_profile_name", + container_group_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^(?!.*--)[a-z0-9]([-a-z0-9]*[a-z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, container_group_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerGroupProfileName": _SERIALIZER.url( + "container_group_profile_name", + container_group_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^(?!.*--)[a-z0-9]([-a-z0-9]*[a-z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerGroupProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.ContainerInstanceManagementClient`'s + :attr:`container_group_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.ContainerGroupProfile"]: + """Get a list of container group profiles in the specified subscription. + + Get a list of container group profiles in the specified subscription. This operation returns + properties of each container group profile including containers, image registry credentials, + restart policy, IP address type, OS type,volumes,current revision number, etc. + + :return: An iterator like instance of either ContainerGroupProfile or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _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[_models.ContainerGroupProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerGroupProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ContainerGroupProfile"]: + """Get a list of container group profiles in the specified subscription and resource group. + + Get a list of container group profiles in a specified subscription and resource group. This + operation returns properties of each container group profile including containers, image + registry credentials, restart policy, IP address type, OS type volumes, current revision + number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ContainerGroupProfile or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _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[_models.ContainerGroupProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerGroupProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, container_group_profile_name: str, **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Get the properties of the specified container group profile. + + Gets the properties of the specified container group profile in the specified subscription and + resource group. The operation returns the properties of container group profile including + containers, image registry credentials, restart policy, IP address type, OS type, volumes, + current revision number, etc. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ContainerGroupProfile] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + container_group_profile_name: str, + container_group_profile: _models.ContainerGroupProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Create or update container group profiles. + + Create or update container group profiles with specified configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param container_group_profile: The properties of the container group profile to be created or + updated. Required. + :type container_group_profile: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + container_group_profile_name: str, + container_group_profile: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Create or update container group profiles. + + Create or update container group profiles with specified configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param container_group_profile: The properties of the container group profile to be created or + updated. Required. + :type container_group_profile: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + container_group_profile_name: str, + container_group_profile: Union[_models.ContainerGroupProfile, IO[bytes]], + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Create or update container group profiles. + + Create or update container group profiles with specified configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param container_group_profile: The properties of the container group profile to be created or + updated. Is either a ContainerGroupProfile type or a IO[bytes] type. Required. + :type container_group_profile: ~azure.mgmt.containerinstance.models.ContainerGroupProfile or + IO[bytes] + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: 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.ContainerGroupProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container_group_profile, (IOBase, bytes)): + _content = container_group_profile + else: + _json = self._serialize.body(container_group_profile, "ContainerGroupProfile") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def patch( + self, + resource_group_name: str, + container_group_profile_name: str, + properties: _models.ContainerGroupProfilePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Patch container group profiles. + + Patches container group profile with specified properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param properties: The container group profile properties that need to be updated. Required. + :type properties: ~azure.mgmt.containerinstance.models.ContainerGroupProfilePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + container_group_profile_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Patch container group profiles. + + Patches container group profile with specified properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param properties: The container group profile properties that need to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + container_group_profile_name: str, + properties: Union[_models.ContainerGroupProfilePatch, IO[bytes]], + **kwargs: Any + ) -> _models.ContainerGroupProfile: + """Patch container group profiles. + + Patches container group profile with specified properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :param properties: The container group profile properties that need to be updated. Is either a + ContainerGroupProfilePatch type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.containerinstance.models.ContainerGroupProfilePatch or IO[bytes] + :return: ContainerGroupProfile or the result of cls(response) + :rtype: ~azure.mgmt.containerinstance.models.ContainerGroupProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: 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.ContainerGroupProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ContainerGroupProfilePatch") + + _request = build_patch_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerGroupProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, container_group_profile_name: str, **kwargs: Any + ) -> None: + """Delete the specified container group profile. + + Delete the specified container group profile in the specified subscription and resource group. + The operation does not delete other resources provided by the user, such as volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_group_profile_name: The name of the container group profile. Required. + :type container_group_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + container_group_profile_name=container_group_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore 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 afaa82772f278..4ae227c0b1538 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-05-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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,10 +84,12 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +106,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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,11 +116,13 @@ def build_get_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +139,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-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,11 +150,13 @@ def build_create_or_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +175,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-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -174,11 +186,13 @@ def build_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +211,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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -207,11 +221,13 @@ def build_delete_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +244,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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -238,11 +254,13 @@ def build_restart_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +277,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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -269,11 +287,13 @@ def build_stop_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +310,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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -300,11 +320,13 @@ def build_start_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +343,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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -331,11 +353,13 @@ def build_get_outbound_network_dependencies_endpoints_request( # pylint: disabl ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "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 +397,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 +407,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 +418,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 +436,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 +451,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 +467,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. @@ -457,9 +475,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite returns properties of each container group including containers, image registry credentials, restart policy, IP address type, OS type, state, and volumes. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContainerGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -470,7 +488,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 +499,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 +518,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 +533,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 +549,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. @@ -546,16 +557,16 @@ def get(self, resource_group_name: str, container_group_name: str, **kwargs: Any group. The operation returns the properties of each container group including containers, image registry credentials, restart policy, IP address type, OS type, state, and volumes. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +580,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 +601,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 +628,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 +646,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, @@ -688,7 +688,8 @@ def begin_create_or_update( Create or update container groups with specified configurations. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -698,14 +699,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 +710,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 @@ -726,24 +719,17 @@ def begin_create_or_update( Create or update container groups with specified configurations. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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. 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,31 +741,21 @@ 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. Create or update container groups with specified configurations. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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 +782,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 +798,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( @@ -847,7 +822,8 @@ def update( Updates container group tags with specified values. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -856,7 +832,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 +842,7 @@ def update( self, resource_group_name: str, container_group_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -876,16 +851,16 @@ def update( Updates container group tags with specified values. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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,28 +868,29 @@ 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. Updates container group tags with specified values. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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 +908,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 +921,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 +937,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 +957,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( @@ -1036,18 +1001,11 @@ def begin_delete( Delete the specified container group in the specified subscription and resource group. The operation does not delete other resources provided by the user, such as volumes. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +1029,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 +1045,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 +1068,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]: @@ -1152,18 +1110,11 @@ def begin_restart(self, resource_group_name: str, container_group_name: str, **k Restarts all containers in a container group in place. If container image has updates, new image will be downloaded. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +1128,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 +1137,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 +1151,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 @@ -1220,16 +1168,16 @@ def stop( # pylint: disable=inconsistent-return-statements Stops all containers in a container group. Compute resources will be deallocated and billing will stop. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +1191,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 +1213,10 @@ 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" - } - - 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 +1228,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]: @@ -1327,18 +1270,11 @@ def begin_start(self, resource_group_name: str, container_group_name: str, **kwa Starts all containers in a container group. Compute resources will be allocated and billing will start. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +1288,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 +1297,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 +1311,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 @@ -1395,16 +1328,16 @@ def get_outbound_network_dependencies_endpoints( # pylint: disable=name-too-lon Gets all the network dependencies for this container group to allow complete control of network setting and configuration. For container groups, this will always be an empty list. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 +1351,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 +1372,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 277332c3a6549..402c91e64a962 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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,12 +61,14 @@ def build_list_logs_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), "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 +89,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-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -94,12 +100,14 @@ def build_execute_command_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), "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 +126,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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,12 +136,14 @@ def build_attach_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, "str"), "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") @@ -178,7 +188,8 @@ def list_logs( Get the logs for a specified container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -190,12 +201,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 +219,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 +227,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 +243,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( @@ -262,7 +266,8 @@ def execute_command( Executes a command for a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str @@ -273,7 +278,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 +289,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 @@ -295,18 +299,18 @@ def execute_command( Executes a command for a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str :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 +322,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. @@ -326,24 +330,22 @@ def execute_command( Executes a command for a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :type container_group_name: str :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 +363,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 +377,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 +393,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( @@ -413,18 +409,18 @@ def attach( Attach to the output stream of a specific container instance in a specified resource group and container group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param container_group_name: The name of the container group. Required. :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 +434,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 +456,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 c0cfe232e80a7..b7ad2e02b809b 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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,10 +53,10 @@ def build_list_usage_request(location: str, subscription_id: str, **kwargs: Any) ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,10 +81,10 @@ def build_list_cached_images_request(location: str, subscription_id: str, **kwar ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,10 +109,10 @@ def build_list_capabilities_request(location: str, subscription_id: str, **kwarg ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,9 +146,8 @@ def __init__(self, *args, **kwargs): def list_usage(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Get the usage for a subscription. - :param location: The identifier for the physical azure location. Required. + :param location: The name of the Azure region. 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,19 +219,14 @@ 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. Get the list of cached images on specific OS type for a subscription in a region. - :param location: The identifier for the physical azure location. Required. + :param location: The name of the Azure region. 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,19 +298,14 @@ 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. Get the list of CPU/memory/GPU capabilities of a region. - :param location: The identifier for the physical azure location. Required. + :param location: The name of the Azure region. 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 3252348a0655f..3b750f69232cd 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-05-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 d61100345adb9..eccbeed67ad03 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-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,12 +57,14 @@ def build_delete_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, "str"), "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 +94,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 +109,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( @@ -144,20 +154,13 @@ def begin_delete( Delete container group virtual network association links. The operation does not delete other resources provided by the user. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param virtual_network_name: The name of the virtual network. Required. :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 +174,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 +184,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 +198,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 8b7cd6445d035..f111cbec97184 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.location.list_cached_images( @@ -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-05-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 a87b989cd4f59..c62ac513402fb 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.location.list_capabilities( @@ -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-05-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 bf224a5d78c8c..b7a7784510253 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.containers.attach( @@ -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-05-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 48af00573a2e9..8bde95f563ef8 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.containers.execute_command( @@ -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-05-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 14f41f58f69dd..8595e0e0f8cc9 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.begin_create_or_update( @@ -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-05-01-preview/examples/ContainerGroupCreateConfidential.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_create_or_update_standby_pool.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_create_or_update_standby_pool.py new file mode 100644 index 0000000000000..9995a99cedead --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_create_or_update_standby_pool.py @@ -0,0 +1,55 @@ +# 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_group_create_or_update_standby_pool.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_groups.begin_create_or_update( + resource_group_name="demo", + container_group_name="demo1", + container_group={ + "location": "west us", + "properties": { + "containerGroupProfile": { + "id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp", + "revision": 1, + }, + "containers": [{"name": "demo1", "properties": {"configMap": {"keyValuePairs": {"Newkey": "value"}}}}], + "standbyPoolProfile": { + "id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool" + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupCreateOrUpdateStandbyPool.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 f037ed962287f..b912076f1e406 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.begin_create_or_update( @@ -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-05-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 8366013d9cdbf..c2715df00e722 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.begin_create_or_update( @@ -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-05-01-preview/examples/ContainerGroupExtensions.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_create_confidential.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_create_confidential.py new file mode 100644 index 0000000000000..7b92f39dad8a5 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_create_confidential.py @@ -0,0 +1,68 @@ +# 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_group_profile_create_or_update_create_confidential.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.create_or_update( + resource_group_name="demo", + container_group_profile_name="demo1", + container_group_profile={ + "location": "westeurope", + "properties": { + "confidentialComputeProperties": { + "ccePolicy": "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19" + }, + "containers": [ + { + "name": "accdemo", + "properties": { + "command": [], + "environmentVariables": [], + "image": "confiimage", + "ports": [{"port": 8000}], + "resources": {"requests": {"cpu": 1, "memoryInGB": 1.5}}, + "securityContext": {"capabilities": {"add": ["CAP_NET_ADMIN"]}, "privileged": False}, + }, + } + ], + "imageRegistryCredentials": [], + "ipAddress": {"ports": [{"port": 8000, "protocol": "TCP"}], "type": "Public"}, + "osType": "Linux", + "sku": "Confidential", + }, + "zones": ["1"], + }, + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_CreateConfidential.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_encryption_properties.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_encryption_properties.py new file mode 100644 index 0000000000000..ec7389df39d0f --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_encryption_properties.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profile_create_or_update_encryption_properties.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.create_or_update( + resource_group_name="demo", + container_group_profile_name="demo1", + container_group_profile={ + "location": "eastus2", + "properties": { + "containers": [ + { + "name": "demo1", + "properties": { + "command": [], + "environmentVariables": [], + "image": "nginx", + "ports": [{"port": 80}], + "resources": {"requests": {"cpu": 1, "memoryInGB": 1.5}}, + }, + } + ], + "encryptionProperties": { + "identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity", + "keyName": "test-key", + "keyVersion": "", + "vaultBaseUrl": "https://testkeyvault.vault.azure.net", + }, + "imageRegistryCredentials": [], + "ipAddress": {"ports": [{"port": 80, "protocol": "TCP"}], "type": "Public"}, + "osType": "Linux", + }, + "zones": ["1"], + }, + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_EncryptionProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_extensions.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_extensions.py new file mode 100644 index 0000000000000..acf5e175be980 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_create_or_update_extensions.py @@ -0,0 +1,78 @@ +# 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_group_profile_create_or_update_extensions.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.create_or_update( + resource_group_name="demo", + container_group_profile_name="demo1", + container_group_profile={ + "location": "eastus2", + "properties": { + "containers": [ + { + "name": "demo1", + "properties": { + "command": [], + "environmentVariables": [], + "image": "nginx", + "ports": [{"port": 80}], + "resources": {"requests": {"cpu": 1, "memoryInGB": 1.5}}, + }, + } + ], + "extensions": [ + { + "name": "kube-proxy", + "properties": { + "extensionType": "kube-proxy", + "protectedSettings": {"kubeConfig": ""}, + "settings": {"clusterCidr": "10.240.0.0/16", "kubeVersion": "v1.9.10"}, + "version": "1.0", + }, + }, + { + "name": "vk-realtime-metrics", + "properties": {"extensionType": "realtime-metrics", "version": "1.0"}, + }, + ], + "imageRegistryCredentials": [], + "ipAddress": {"ports": [{"port": 80, "protocol": "TCP"}], "type": "Private"}, + "osType": "Linux", + }, + "zones": ["1"], + }, + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_Extensions.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_get_by_revision_number.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_get_by_revision_number.py new file mode 100644 index 0000000000000..c32a0dd2f7df9 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_get_by_revision_number.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profile_get_by_revision_number.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profile.get_by_revision_number( + resource_group_name="demo", + container_group_profile_name="demo1", + revision_number="1", + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileGetByRevisionNumber.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_list_all_revisions.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_list_all_revisions.py new file mode 100644 index 0000000000000..af8ac8248b1ec --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profile_list_all_revisions.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profile_list_all_revisions.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profile.list_all_revisions( + resource_group_name="demo", + container_group_profile_name="demo1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileListAllRevisions.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_create_or_update.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_create_or_update.py new file mode 100644 index 0000000000000..79a9668b4f80d --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_create_or_update.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profiles_create_or_update.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.create_or_update( + resource_group_name="demo", + container_group_profile_name="demo1", + container_group_profile={ + "location": "west us", + "properties": { + "containers": [ + { + "name": "demo1", + "properties": { + "command": [], + "environmentVariables": [], + "image": "nginx", + "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": {"pod-uuid": "test-metadata-value"}, + "workspaceId": "workspaceid", + "workspaceKey": "workspaceKey", + "workspaceResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace", + } + }, + "imageRegistryCredentials": [], + "ipAddress": {"ports": [{"port": 80, "protocol": "TCP"}], "type": "Public"}, + "osType": "Linux", + "volumes": [ + { + "azureFile": { + "shareName": "shareName", + "storageAccountKey": "accountKey", + "storageAccountName": "accountName", + }, + "name": "volume1", + }, + {"emptyDir": {}, "name": "volume2"}, + { + "name": "volume3", + "secret": {"secretKey1": "SecretValue1InBase64", "secretKey2": "SecretValue2InBase64"}, + }, + ], + }, + "zones": ["1"], + }, + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesCreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_delete.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_delete.py new file mode 100644 index 0000000000000..6d6b02fbfe755 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profiles_delete.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="00000000-0000-0000-0000-000000000000", + ) + + client.container_group_profiles.delete( + resource_group_name="demo", + container_group_profile_name="demo1", + ) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_get.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_get.py new file mode 100644 index 0000000000000..32106f87ab660 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profiles_get.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.get( + resource_group_name="demo", + container_group_profile_name="demo1", + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGet.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_get_priority.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_get_priority.py new file mode 100644 index 0000000000000..42cd14fffda8e --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_get_priority.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profiles_get_priority.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.get( + resource_group_name="demo", + container_group_profile_name="demo1", + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGetPriority.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_list.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_list.py new file mode 100644 index 0000000000000..4206aaef67721 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_list.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profiles_list.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesList.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_list_by_resource_group.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_list_by_resource_group.py new file mode 100644 index 0000000000000..888588bd2c929 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_list_by_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profiles_list_by_resource_group.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.list_by_resource_group( + resource_group_name="demo", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_patch.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_patch.py new file mode 100644 index 0000000000000..ba009fb17d70b --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_group_profiles_patch.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.containerinstance import ContainerInstanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-containerinstance +# USAGE + python container_group_profiles_patch.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.patch( + resource_group_name="demoResource", + container_group_profile_name="demo1", + properties={"tags": {"tag1key": "tag1Value", "tag2key": "tag2Value"}}, + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesPatch.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 6cf542b0f18cf..9acf3f8bac12b 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.location.list_usage( @@ -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-05-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 c91b5967b174a..9f0f1547cc1c7 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.begin_create_or_update( @@ -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-05-01-preview/examples/ContainerGroupsCreateOrUpdate.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 669feee2cb7b3..7afd66c684c90 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.begin_create_or_update( @@ -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-05-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 b668f351e487d..15f8c832302c1 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.begin_delete( @@ -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-05-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 acb5bdddb7d06..56c75cb1046c4 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.get( @@ -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-05-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 80b590ce3948c..7bbcc1a466bce 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.get( @@ -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-05-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 32cd7a87ccc44..b534f3bb12276 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.get( @@ -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-05-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 e045d4755eb45..546844ad6e152 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.list() @@ -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-05-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 1004d47e11e26..ef1b0431b9d7c 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.container_groups.list_by_resource_group( @@ -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-05-01-preview/examples/ContainerGroupsListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_profile_create_or_update_create_priority.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_profile_create_or_update_create_priority.py new file mode 100644 index 0000000000000..d913940cd4a1b --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_samples/container_groups_profile_create_or_update_create_priority.py @@ -0,0 +1,61 @@ +# 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_profile_create_or_update_create_priority.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="00000000-0000-0000-0000-000000000000", + ) + + response = client.container_group_profiles.create_or_update( + resource_group_name="demo", + container_group_profile_name="demo1", + container_group_profile={ + "location": "eastus", + "properties": { + "containers": [ + { + "name": "test-container-001", + "properties": { + "command": ["/bin/sh", "-c", "sleep 10"], + "image": "alpine:latest", + "resources": {"requests": {"cpu": 1, "memoryInGB": 1}}, + }, + } + ], + "osType": "Linux", + "priority": "Spot", + "restartPolicy": "Never", + "sku": "Standard", + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsProfileCreateOrUpdate_CreatePriority.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 e26484aa35195..978ab25144b5f 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 """ @@ -26,16 +27,15 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - 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-05-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 0ba41154670a5..d40773c08b2b5 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 """ @@ -26,16 +27,15 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - 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-05-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 58c6a41b9992e..5b5969ca0aacc 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 """ @@ -26,16 +27,15 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - 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-05-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 4328f098b5a22..855578377701e 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 """ @@ -26,7 +27,7 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.containers.list_logs( @@ -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-05-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 eaf5f595d3fde..a02cb7e8094c6 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-05-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 6d45c381ce377..3f588b61c8696 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 """ @@ -26,17 +27,16 @@ def main(): client = ContainerInstanceManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - 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-05-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 0000000000000..e965bd77cfd75 --- /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_group_profile_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profile_operations.py new file mode 100644 index 0000000000000..086b738307d9c --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profile_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 TestContainerInstanceManagementContainerGroupProfileOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ContainerInstanceManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_all_revisions(self, resource_group): + response = self.client.container_group_profile.list_all_revisions( + resource_group_name=resource_group.name, + container_group_profile_name="str", + api_version="2024-05-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_by_revision_number(self, resource_group): + response = self.client.container_group_profile.get_by_revision_number( + resource_group_name=resource_group.name, + container_group_profile_name="str", + revision_number="str", + api_version="2024-05-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_group_profile_operations_async.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profile_operations_async.py new file mode 100644 index 0000000000000..cb1f53b484d4c --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profile_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.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 TestContainerInstanceManagementContainerGroupProfileOperationsAsync(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_all_revisions(self, resource_group): + response = self.client.container_group_profile.list_all_revisions( + resource_group_name=resource_group.name, + container_group_profile_name="str", + api_version="2024-05-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_by_revision_number(self, resource_group): + response = await self.client.container_group_profile.get_by_revision_number( + resource_group_name=resource_group.name, + container_group_profile_name="str", + revision_number="str", + api_version="2024-05-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_group_profiles_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profiles_operations.py new file mode 100644 index 0000000000000..f32173dcbfcca --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profiles_operations.py @@ -0,0 +1,268 @@ +# 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 TestContainerInstanceManagementContainerGroupProfilesOperations(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_group_profiles.list( + api_version="2024-05-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_group_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-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_group_profiles.get( + resource_group_name=resource_group.name, + container_group_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.container_group_profiles.create_or_update( + resource_group_name=resource_group.name, + container_group_profile_name="str", + container_group_profile={ + "containers": [ + { + "name": "str", + "command": ["str"], + "configMap": {"keyValuePairs": {"str": "str"}}, + "environmentVariables": [{"name": "str", "secureValue": "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, + }, + "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, + }, + "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}, + }, + "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", + } + }, + "encryptionProperties": { + "keyName": "str", + "keyVersion": "str", + "vaultBaseUrl": "str", + "identity": "str", + }, + "extensions": [ + {"name": "str", "extensionType": "str", "protectedSettings": {}, "settings": {}, "version": "str"} + ], + "id": "str", + "imageRegistryCredentials": [ + {"server": "str", "identity": "str", "identityUrl": "str", "password": "str", "username": "str"} + ], + "initContainers": [ + { + "name": "str", + "command": ["str"], + "environmentVariables": [{"name": "str", "secureValue": "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}], + } + ], + "ipAddress": { + "ports": [{"port": 0, "protocol": "str"}], + "type": "str", + "autoGeneratedDomainNameLabelScope": "Unsecure", + "dnsNameLabel": "str", + "fqdn": "str", + "ip": "str", + }, + "location": "str", + "name": "str", + "priority": "str", + "restartPolicy": "str", + "revision": 0, + "sku": "str", + "tags": {"str": "str"}, + "type": "str", + "volumes": [ + { + "name": "str", + "azureFile": { + "shareName": "str", + "storageAccountName": "str", + "readOnly": bool, + "storageAccountKey": "str", + }, + "emptyDir": {}, + "gitRepo": {"repository": "str", "directory": "str", "revision": "str"}, + "secret": {"str": "str"}, + } + ], + "zones": ["str"], + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_patch(self, resource_group): + response = self.client.container_group_profiles.patch( + resource_group_name=resource_group.name, + container_group_profile_name="str", + properties={"tags": {"str": "str"}}, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.container_group_profiles.delete( + resource_group_name=resource_group.name, + container_group_profile_name="str", + api_version="2024-05-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_group_profiles_operations_async.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profiles_operations_async.py new file mode 100644 index 0000000000000..a3d7248655214 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_group_profiles_operations_async.py @@ -0,0 +1,269 @@ +# 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 TestContainerInstanceManagementContainerGroupProfilesOperationsAsync(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_group_profiles.list( + api_version="2024-05-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_group_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-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_group_profiles.get( + resource_group_name=resource_group.name, + container_group_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.container_group_profiles.create_or_update( + resource_group_name=resource_group.name, + container_group_profile_name="str", + container_group_profile={ + "containers": [ + { + "name": "str", + "command": ["str"], + "configMap": {"keyValuePairs": {"str": "str"}}, + "environmentVariables": [{"name": "str", "secureValue": "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, + }, + "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, + }, + "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}, + }, + "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", + } + }, + "encryptionProperties": { + "keyName": "str", + "keyVersion": "str", + "vaultBaseUrl": "str", + "identity": "str", + }, + "extensions": [ + {"name": "str", "extensionType": "str", "protectedSettings": {}, "settings": {}, "version": "str"} + ], + "id": "str", + "imageRegistryCredentials": [ + {"server": "str", "identity": "str", "identityUrl": "str", "password": "str", "username": "str"} + ], + "initContainers": [ + { + "name": "str", + "command": ["str"], + "environmentVariables": [{"name": "str", "secureValue": "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}], + } + ], + "ipAddress": { + "ports": [{"port": 0, "protocol": "str"}], + "type": "str", + "autoGeneratedDomainNameLabelScope": "Unsecure", + "dnsNameLabel": "str", + "fqdn": "str", + "ip": "str", + }, + "location": "str", + "name": "str", + "priority": "str", + "restartPolicy": "str", + "revision": 0, + "sku": "str", + "tags": {"str": "str"}, + "type": "str", + "volumes": [ + { + "name": "str", + "azureFile": { + "shareName": "str", + "storageAccountName": "str", + "readOnly": bool, + "storageAccountKey": "str", + }, + "emptyDir": {}, + "gitRepo": {"repository": "str", "directory": "str", "revision": "str"}, + "secret": {"str": "str"}, + } + ], + "zones": ["str"], + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_patch(self, resource_group): + response = await self.client.container_group_profiles.patch( + resource_group_name=resource_group.name, + container_group_profile_name="str", + properties={"tags": {"str": "str"}}, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.container_group_profiles.delete( + resource_group_name=resource_group.name, + container_group_profile_name="str", + api_version="2024-05-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.py b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations.py new file mode 100644 index 0000000000000..5aa36a394fc91 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations.py @@ -0,0 +1,347 @@ +# 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-05-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-05-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-05-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": [ + { + "name": "str", + "command": ["str"], + "configMap": {"keyValuePairs": {"str": "str"}}, + "environmentVariables": [{"name": "str", "secureValue": "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, + }, + "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, + }, + "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}, + }, + "securityContext": { + "allowPrivilegeEscalation": bool, + "capabilities": {"add": ["str"], "drop": ["str"]}, + "privileged": bool, + "runAsGroup": 0, + "runAsUser": 0, + "seccompProfile": "str", + }, + "volumeMounts": [{"mountPath": "str", "name": "str", "readOnly": bool}], + } + ], + "confidentialComputeProperties": {"ccePolicy": "str"}, + "containerGroupProfile": {"id": "str", "revision": 0}, + "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", "username": "str"} + ], + "initContainers": [ + { + "name": "str", + "command": ["str"], + "environmentVariables": [{"name": "str", "secureValue": "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", + }, + "isCreatedFromStandbyPool": bool, + "location": "str", + "name": "str", + "osType": "str", + "priority": "str", + "provisioningState": "str", + "restartPolicy": "str", + "sku": "str", + "standbyPoolProfile": {"failContainerGroupCreateOnReuseFailure": bool, "id": "str"}, + "subnetIds": [{"id": "str", "name": "str"}], + "tags": {"str": "str"}, + "type": "str", + "volumes": [ + { + "name": "str", + "azureFile": { + "shareName": "str", + "storageAccountName": "str", + "readOnly": bool, + "storageAccountKey": "str", + }, + "emptyDir": {}, + "gitRepo": {"repository": "str", "directory": "str", "revision": "str"}, + "secret": {"str": "str"}, + } + ], + "zones": ["str"], + }, + api_version="2024-05-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-05-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-05-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-05-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-05-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-05-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-05-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 0000000000000..483ef447d8b17 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/generated_tests/test_container_instance_management_container_groups_operations_async.py @@ -0,0 +1,362 @@ +# 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-05-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-05-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-05-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": [ + { + "name": "str", + "command": ["str"], + "configMap": {"keyValuePairs": {"str": "str"}}, + "environmentVariables": [{"name": "str", "secureValue": "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, + }, + "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, + }, + "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}, + }, + "securityContext": { + "allowPrivilegeEscalation": bool, + "capabilities": {"add": ["str"], "drop": ["str"]}, + "privileged": bool, + "runAsGroup": 0, + "runAsUser": 0, + "seccompProfile": "str", + }, + "volumeMounts": [{"mountPath": "str", "name": "str", "readOnly": bool}], + } + ], + "confidentialComputeProperties": {"ccePolicy": "str"}, + "containerGroupProfile": {"id": "str", "revision": 0}, + "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", "username": "str"} + ], + "initContainers": [ + { + "name": "str", + "command": ["str"], + "environmentVariables": [{"name": "str", "secureValue": "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", + }, + "isCreatedFromStandbyPool": bool, + "location": "str", + "name": "str", + "osType": "str", + "priority": "str", + "provisioningState": "str", + "restartPolicy": "str", + "sku": "str", + "standbyPoolProfile": {"failContainerGroupCreateOnReuseFailure": bool, "id": "str"}, + "subnetIds": [{"id": "str", "name": "str"}], + "tags": {"str": "str"}, + "type": "str", + "volumes": [ + { + "name": "str", + "azureFile": { + "shareName": "str", + "storageAccountName": "str", + "readOnly": bool, + "storageAccountKey": "str", + }, + "emptyDir": {}, + "gitRepo": {"repository": "str", "directory": "str", "revision": "str"}, + "secret": {"str": "str"}, + } + ], + "zones": ["str"], + }, + api_version="2024-05-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-05-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-05-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-05-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-05-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-05-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-05-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 0000000000000..7d98e5b3708d4 --- /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-05-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-05-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-05-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 0000000000000..7953336c2ad3d --- /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-05-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-05-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-05-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 0000000000000..67413abe1b7e6 --- /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-05-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-05-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-05-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 0000000000000..ab4c08275d346 --- /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-05-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-05-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-05-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 0000000000000..cf615891fc51c --- /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-05-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 0000000000000..07bc78bc7caa9 --- /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-05-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 0000000000000..1a5d0c197c992 --- /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-05-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 0000000000000..6f689761a71c8 --- /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-05-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 b2e316db17b03..ada7b011808e0 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", )