diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json index 1f99a035200e..88d55f9a646a 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "62815acf41c163d6e0309dd791bd3476016ffd34", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.16.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.7", + "@autorest/modelerfour@4.24.3" ], - "commit": "90b7b5da32d8e9e2d22d0814aed7207c823ba79a", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/mobilenetwork/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/mobilenetwork/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/mobilenetwork/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py index db3577700ad7..f775e9c3af5c 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MobileNetworkManagementClient'] + +__all__ = [ + "MobileNetworkManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_configuration.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_configuration.py index 9de0a45a56ea..66e0957c8d7a 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_configuration.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class MobileNetworkManagementClientConfiguration(Configuration): # pylint: disa Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-11-01". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MobileNetworkManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", "2022-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-mobilenetwork/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-mobilenetwork/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - 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.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py index b7879f5cdc5a..11aef5196d36 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py @@ -9,22 +9,38 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from ._configuration import MobileNetworkManagementClientConfiguration -from .operations import AttachedDataNetworksOperations, DataNetworksOperations, MobileNetworksOperations, Operations, PacketCoreControlPlaneVersionsOperations, PacketCoreControlPlanesOperations, PacketCoreDataPlanesOperations, ServicesOperations, SimGroupsOperations, SimPoliciesOperations, SimsOperations, SitesOperations, SlicesOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + AttachedDataNetworksOperations, + DataNetworksOperations, + MobileNetworksOperations, + Operations, + PacketCoreControlPlaneOperations, + PacketCoreControlPlaneVersionsOperations, + PacketCoreControlPlanesOperations, + PacketCoreDataPlanesOperations, + ServicesOperations, + SimGroupsOperations, + SimOperations, + SimPoliciesOperations, + SimsOperations, + SitesOperations, + SlicesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MobileNetworkManagementClient: # pylint: disable=too-many-instance-attributes - """The resources in this swagger specification will be used to manage attached data network - resources in mobile network attached to a particular packet core instance. + +class MobileNetworkManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The resources in this API specification will be used to manage attached data network resources + in mobile network attached to a particular packet core instance. :ivar attached_data_networks: AttachedDataNetworksOperations operations :vartype attached_data_networks: @@ -33,17 +49,14 @@ class MobileNetworkManagementClient: # pylint: disable=too-many-instance-attr :vartype data_networks: azure.mgmt.mobilenetwork.operations.DataNetworksOperations :ivar mobile_networks: MobileNetworksOperations operations :vartype mobile_networks: azure.mgmt.mobilenetwork.operations.MobileNetworksOperations - :ivar sites: SitesOperations operations - :vartype sites: azure.mgmt.mobilenetwork.operations.SitesOperations - :ivar sim_groups: SimGroupsOperations operations - :vartype sim_groups: azure.mgmt.mobilenetwork.operations.SimGroupsOperations - :ivar sims: SimsOperations operations - :vartype sims: azure.mgmt.mobilenetwork.operations.SimsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.mobilenetwork.operations.Operations :ivar packet_core_control_planes: PacketCoreControlPlanesOperations operations :vartype packet_core_control_planes: azure.mgmt.mobilenetwork.operations.PacketCoreControlPlanesOperations + :ivar packet_core_control_plane: PacketCoreControlPlaneOperations operations + :vartype packet_core_control_plane: + azure.mgmt.mobilenetwork.operations.PacketCoreControlPlaneOperations :ivar packet_core_control_plane_versions: PacketCoreControlPlaneVersionsOperations operations :vartype packet_core_control_plane_versions: azure.mgmt.mobilenetwork.operations.PacketCoreControlPlaneVersionsOperations @@ -52,18 +65,26 @@ class MobileNetworkManagementClient: # pylint: disable=too-many-instance-attr azure.mgmt.mobilenetwork.operations.PacketCoreDataPlanesOperations :ivar services: ServicesOperations operations :vartype services: azure.mgmt.mobilenetwork.operations.ServicesOperations + :ivar sims: SimsOperations operations + :vartype sims: azure.mgmt.mobilenetwork.operations.SimsOperations + :ivar sim: SimOperations operations + :vartype sim: azure.mgmt.mobilenetwork.operations.SimOperations + :ivar sim_groups: SimGroupsOperations operations + :vartype sim_groups: azure.mgmt.mobilenetwork.operations.SimGroupsOperations :ivar sim_policies: SimPoliciesOperations operations :vartype sim_policies: azure.mgmt.mobilenetwork.operations.SimPoliciesOperations + :ivar sites: SitesOperations operations + :vartype sites: azure.mgmt.mobilenetwork.operations.SitesOperations :ivar slices: SlicesOperations operations :vartype slices: azure.mgmt.mobilenetwork.operations.SlicesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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 "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-11-01". 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. @@ -76,35 +97,25 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MobileNetworkManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MobileNetworkManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.attached_data_networks = AttachedDataNetworksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_networks = DataNetworksOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.mobile_networks = MobileNetworksOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sites = SitesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sim_groups = SimGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sims = SimsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( + self.data_networks = DataNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.mobile_networks = MobileNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.packet_core_control_planes = PacketCoreControlPlanesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.packet_core_control_planes = PacketCoreControlPlanesOperations( + self.packet_core_control_plane = PacketCoreControlPlaneOperations( self._client, self._config, self._serialize, self._deserialize ) self.packet_core_control_plane_versions = PacketCoreControlPlaneVersionsOperations( @@ -113,22 +124,15 @@ def __init__( self.packet_core_data_planes = PacketCoreDataPlanesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sim_policies = SimPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.slices = SlicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sims = SimsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sim = SimOperations(self._client, self._config, self._serialize, self._deserialize) + self.sim_groups = SimGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sim_policies = SimPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sites = SitesOperations(self._client, self._config, self._serialize, self._deserialize) + self.slices = SlicesOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -137,7 +141,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest @@ -150,15 +154,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MobileNetworkManagementClient + def __enter__(self) -> "MobileNetworkManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_patch.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_patch.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_serialization.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_serialization.py new file mode 100644 index 000000000000..2c170e28dbca --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_serialization.py @@ -0,0 +1,1967 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import Optional, Union, AnyStr, IO, Mapping + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from typing import Dict, Any, cast + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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 + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # 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("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str + unicode_str = str + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + 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) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError: + continue + + 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) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **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) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + 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'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + 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: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, 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:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_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:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map # type: ignore + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + 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) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + 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"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_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) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + 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: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + 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) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + 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) + else: + return date_obj diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py index 20971492f129..e5754a47ce68 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b3" +VERSION = "1.0.0b1" diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/__init__.py index a0e06087c46f..d586f2d81bf1 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/__init__.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MobileNetworkManagementClient'] + +__all__ = [ + "MobileNetworkManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_configuration.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_configuration.py index 2fb233a21f10..bfc721b8d265 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_configuration.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class MobileNetworkManagementClientConfiguration(Configuration): # pylint: disa Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-11-01". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MobileNetworkManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", "2022-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-mobilenetwork/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-mobilenetwork/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - 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.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py index 28691c7f3daa..b84b0b99ed0e 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py @@ -9,22 +9,38 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import MobileNetworkManagementClientConfiguration -from .operations import AttachedDataNetworksOperations, DataNetworksOperations, MobileNetworksOperations, Operations, PacketCoreControlPlaneVersionsOperations, PacketCoreControlPlanesOperations, PacketCoreDataPlanesOperations, ServicesOperations, SimGroupsOperations, SimPoliciesOperations, SimsOperations, SitesOperations, SlicesOperations +from .operations import ( + AttachedDataNetworksOperations, + DataNetworksOperations, + MobileNetworksOperations, + Operations, + PacketCoreControlPlaneOperations, + PacketCoreControlPlaneVersionsOperations, + PacketCoreControlPlanesOperations, + PacketCoreDataPlanesOperations, + ServicesOperations, + SimGroupsOperations, + SimOperations, + SimPoliciesOperations, + SimsOperations, + SitesOperations, + SlicesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MobileNetworkManagementClient: # pylint: disable=too-many-instance-attributes - """The resources in this swagger specification will be used to manage attached data network - resources in mobile network attached to a particular packet core instance. + +class MobileNetworkManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The resources in this API specification will be used to manage attached data network resources + in mobile network attached to a particular packet core instance. :ivar attached_data_networks: AttachedDataNetworksOperations operations :vartype attached_data_networks: @@ -33,17 +49,14 @@ class MobileNetworkManagementClient: # pylint: disable=too-many-instance-attr :vartype data_networks: azure.mgmt.mobilenetwork.aio.operations.DataNetworksOperations :ivar mobile_networks: MobileNetworksOperations operations :vartype mobile_networks: azure.mgmt.mobilenetwork.aio.operations.MobileNetworksOperations - :ivar sites: SitesOperations operations - :vartype sites: azure.mgmt.mobilenetwork.aio.operations.SitesOperations - :ivar sim_groups: SimGroupsOperations operations - :vartype sim_groups: azure.mgmt.mobilenetwork.aio.operations.SimGroupsOperations - :ivar sims: SimsOperations operations - :vartype sims: azure.mgmt.mobilenetwork.aio.operations.SimsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.mobilenetwork.aio.operations.Operations :ivar packet_core_control_planes: PacketCoreControlPlanesOperations operations :vartype packet_core_control_planes: azure.mgmt.mobilenetwork.aio.operations.PacketCoreControlPlanesOperations + :ivar packet_core_control_plane: PacketCoreControlPlaneOperations operations + :vartype packet_core_control_plane: + azure.mgmt.mobilenetwork.aio.operations.PacketCoreControlPlaneOperations :ivar packet_core_control_plane_versions: PacketCoreControlPlaneVersionsOperations operations :vartype packet_core_control_plane_versions: azure.mgmt.mobilenetwork.aio.operations.PacketCoreControlPlaneVersionsOperations @@ -52,18 +65,26 @@ class MobileNetworkManagementClient: # pylint: disable=too-many-instance-attr azure.mgmt.mobilenetwork.aio.operations.PacketCoreDataPlanesOperations :ivar services: ServicesOperations operations :vartype services: azure.mgmt.mobilenetwork.aio.operations.ServicesOperations + :ivar sims: SimsOperations operations + :vartype sims: azure.mgmt.mobilenetwork.aio.operations.SimsOperations + :ivar sim: SimOperations operations + :vartype sim: azure.mgmt.mobilenetwork.aio.operations.SimOperations + :ivar sim_groups: SimGroupsOperations operations + :vartype sim_groups: azure.mgmt.mobilenetwork.aio.operations.SimGroupsOperations :ivar sim_policies: SimPoliciesOperations operations :vartype sim_policies: azure.mgmt.mobilenetwork.aio.operations.SimPoliciesOperations + :ivar sites: SitesOperations operations + :vartype sites: azure.mgmt.mobilenetwork.aio.operations.SitesOperations :ivar slices: SlicesOperations operations :vartype slices: azure.mgmt.mobilenetwork.aio.operations.SlicesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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 "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-11-01". 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. @@ -76,35 +97,25 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MobileNetworkManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MobileNetworkManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.attached_data_networks = AttachedDataNetworksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_networks = DataNetworksOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.mobile_networks = MobileNetworksOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sites = SitesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sim_groups = SimGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sims = SimsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( + self.data_networks = DataNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.mobile_networks = MobileNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.packet_core_control_planes = PacketCoreControlPlanesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.packet_core_control_planes = PacketCoreControlPlanesOperations( + self.packet_core_control_plane = PacketCoreControlPlaneOperations( self._client, self._config, self._serialize, self._deserialize ) self.packet_core_control_plane_versions = PacketCoreControlPlaneVersionsOperations( @@ -113,22 +124,15 @@ def __init__( self.packet_core_data_planes = PacketCoreDataPlanesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sim_policies = SimPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.slices = SlicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sims = SimsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sim = SimOperations(self._client, self._config, self._serialize, self._deserialize) + self.sim_groups = SimGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sim_policies = SimPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sites = SitesOperations(self._client, self._config, self._serialize, self._deserialize) + self.slices = SlicesOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -137,7 +141,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_patch.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_patch.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py index 8b9269226627..3173a921e4c3 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py @@ -9,34 +9,39 @@ from ._attached_data_networks_operations import AttachedDataNetworksOperations from ._data_networks_operations import DataNetworksOperations from ._mobile_networks_operations import MobileNetworksOperations -from ._sites_operations import SitesOperations -from ._sim_groups_operations import SimGroupsOperations -from ._sims_operations import SimsOperations from ._operations import Operations from ._packet_core_control_planes_operations import PacketCoreControlPlanesOperations +from ._packet_core_control_plane_operations import PacketCoreControlPlaneOperations from ._packet_core_control_plane_versions_operations import PacketCoreControlPlaneVersionsOperations from ._packet_core_data_planes_operations import PacketCoreDataPlanesOperations from ._services_operations import ServicesOperations +from ._sims_operations import SimsOperations +from ._sim_operations import SimOperations +from ._sim_groups_operations import SimGroupsOperations from ._sim_policies_operations import SimPoliciesOperations +from ._sites_operations import SitesOperations from ._slices_operations import SlicesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AttachedDataNetworksOperations', - 'DataNetworksOperations', - 'MobileNetworksOperations', - 'SitesOperations', - 'SimGroupsOperations', - 'SimsOperations', - 'Operations', - 'PacketCoreControlPlanesOperations', - 'PacketCoreControlPlaneVersionsOperations', - 'PacketCoreDataPlanesOperations', - 'ServicesOperations', - 'SimPoliciesOperations', - 'SlicesOperations', + "AttachedDataNetworksOperations", + "DataNetworksOperations", + "MobileNetworksOperations", + "Operations", + "PacketCoreControlPlanesOperations", + "PacketCoreControlPlaneOperations", + "PacketCoreControlPlaneVersionsOperations", + "PacketCoreDataPlanesOperations", + "ServicesOperations", + "SimsOperations", + "SimOperations", + "SimGroupsOperations", + "SimPoliciesOperations", + "SitesOperations", + "SlicesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_attached_data_networks_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_attached_data_networks_operations.py index 01d5a0c39acb..a5e5f3ba2672 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_attached_data_networks_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_attached_data_networks_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._attached_data_networks_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_packet_core_data_plane_request, build_update_tags_request -T = TypeVar('T') +from ...operations._attached_data_networks_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_packet_core_data_plane_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AttachedDataNetworksOperations: """ .. warning:: @@ -45,7 +66,6 @@ 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 self, resource_group_name: str, @@ -55,50 +75,55 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, packet_core_control_plane_name: str, @@ -109,12 +134,13 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the specified attached data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_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. @@ -126,19 +152,18 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, @@ -146,37 +171,37 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } @distributed_trace_async async def get( @@ -190,49 +215,53 @@ async def get( """Gets information about the specified attached data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AttachedDataNetwork, or the result of cls(response) + :return: AttachedDataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AttachedDataNetwork] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,15 +269,16 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } async def _create_or_update_initial( self, @@ -256,65 +286,78 @@ async def _create_or_update_initial( packet_core_control_plane_name: str, packet_core_data_plane_name: str, attached_data_network_name: str, - parameters: _models.AttachedDataNetwork, + parameters: Union[_models.AttachedDataNetwork, IO], **kwargs: Any ) -> _models.AttachedDataNetwork: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] - - _json = self._serialize.body(parameters, 'AttachedDataNetwork') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.AttachedDataNetwork] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachedDataNetwork") + + request = build_create_or_update_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, @@ -322,20 +365,73 @@ async def begin_create_or_update( packet_core_data_plane_name: str, attached_data_network_name: str, parameters: _models.AttachedDataNetwork, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.AttachedDataNetwork]: - """Creates or updates an attached data network. + """Creates or updates an attached data network. Must be created in the same location as its parent + packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_name: str :param parameters: Parameters supplied to the create or update attached data network operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork + :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 AttachedDataNetwork or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AttachedDataNetwork]: + """Creates or updates an attached data network. Must be created in the same location as its parent + packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to the create or update attached data network operation. + Required. + :type parameters: IO + :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 @@ -348,22 +444,64 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: Union[_models.AttachedDataNetwork, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AttachedDataNetwork]: + """Creates or updates an attached data network. Must be created in the same location as its parent + packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to the create or update attached data network operation. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork 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. + :return: An instance of AsyncLROPoller that returns either AttachedDataNetwork or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AttachedDataNetwork] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, @@ -371,41 +509,42 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, @@ -413,60 +552,144 @@ async def update_tags( packet_core_data_plane_name: str, attached_data_network_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AttachedDataNetwork: """Updates an attached data network tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_name: str - :param parameters: Parameters supplied to update attached data network tags. + :param parameters: Parameters supplied to update attached data network tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: AttachedDataNetwork, or the result of cls(response) + :return: AttachedDataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AttachedDataNetwork: + """Updates an attached data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to update attached data network tags. Required. + :type parameters: IO + :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: AttachedDataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.AttachedDataNetwork: + """Updates an attached data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to update attached data network tags. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: AttachedDataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] + api_version: Literal["2022-11-01"] = 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.AttachedDataNetwork] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -474,15 +697,16 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } @distributed_trace def list_by_packet_core_data_plane( @@ -491,62 +715,69 @@ def list_by_packet_core_data_plane( packet_core_control_plane_name: str, packet_core_data_plane_name: str, **kwargs: Any - ) -> AsyncIterable[_models.AttachedDataNetworkListResult]: + ) -> AsyncIterable["_models.AttachedDataNetwork"]: """Gets all the attached data networks associated with a packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AttachedDataNetworkListResult or the result of - cls(response) + :return: An iterator like instance of either AttachedDataNetwork or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.AttachedDataNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AttachedDataNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_packet_core_data_plane_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_packet_core_data_plane.metadata['url'], + template_url=self.list_by_packet_core_data_plane.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_packet_core_data_plane_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - packet_core_data_plane_name=packet_core_data_plane_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -554,16 +785,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AttachedDataNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -574,8 +803,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_packet_core_data_plane.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks"} # type: ignore + list_by_packet_core_data_plane.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_data_networks_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_data_networks_operations.py index 75bfffcebfe8..54792d7b9f6c 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_data_networks_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_data_networks_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_networks_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_mobile_network_request, build_update_tags_request -T = TypeVar('T') +from ...operations._data_networks_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_mobile_network_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataNetworksOperations: """ .. warning:: @@ -45,71 +66,68 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, data_network_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, mobile_network_name: str, data_network_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_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. @@ -121,108 +139,107 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, data_network_name: str, **kwargs: Any ) -> _models.DataNetwork: """Gets information about the specified data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataNetwork, or the result of cls(response) + :return: DataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.DataNetwork] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,97 +247,199 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } async def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, data_network_name: str, - parameters: _models.DataNetwork, + parameters: Union[_models.DataNetwork, IO], **kwargs: Any ) -> _models.DataNetwork: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] - - _json = self._serialize.body(parameters, 'DataNetwork') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.DataNetwork] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataNetwork") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, data_network_name: str, parameters: _models.DataNetwork, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DataNetwork]: - """Creates or updates a data network. + """Creates or updates a data network. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_name: str :param parameters: Parameters supplied to the create or update data network operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.DataNetwork + :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 DataNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.DataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataNetwork]: + """Creates or updates a data network. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to the create or update data network operation. + Required. + :type parameters: IO + :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 DataNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.DataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: Union[_models.DataNetwork, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataNetwork]: + """Creates or updates a data network. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to the create or update data network operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.DataNetwork 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 @@ -332,120 +451,198 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either DataNetwork or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.DataNetwork] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataNetwork] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, mobile_network_name: str, data_network_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataNetwork: """Updates data network tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_name: str - :param parameters: Parameters supplied to update data network tags. + :param parameters: Parameters supplied to update data network tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: DataNetwork, or the result of cls(response) + :return: DataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataNetwork: + """Updates data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to update data network tags. Required. + :type parameters: IO + :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: DataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.DataNetwork: + """Updates data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to update data network tags. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: DataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] + api_version: Literal["2022-11-01"] = 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.DataNetwork] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -453,74 +650,79 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataNetworkListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataNetwork"]: """Lists all data networks in the mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataNetworkListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.DataNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataNetwork or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.DataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.DataNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -528,16 +730,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -548,8 +748,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_mobile_networks_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_mobile_networks_operations.py index a13e4ae2e344..942539184447 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_mobile_networks_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_mobile_networks_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._mobile_networks_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_sim_ids_request_initial, build_update_tags_request -T = TypeVar('T') +from ...operations._mobile_networks_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MobileNetworksOperations: """ .. warning:: @@ -45,66 +67,65 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_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. @@ -116,103 +137,101 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> _models.MobileNetwork: + async def get(self, resource_group_name: str, mobile_network_name: str, **kwargs: Any) -> _models.MobileNetwork: """Gets information about the specified mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MobileNetwork, or the result of cls(response) + :return: MobileNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.MobileNetwork] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,92 +239,113 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } async def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, - parameters: _models.MobileNetwork, + parameters: Union[_models.MobileNetwork, IO], **kwargs: Any ) -> _models.MobileNetwork: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] - - _json = self._serialize.body(parameters, 'MobileNetwork') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.MobileNetwork] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MobileNetwork") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, parameters: _models.MobileNetwork, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.MobileNetwork]: """Creates or updates a mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param parameters: Parameters supplied to the create or update mobile network operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.MobileNetwork + :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 @@ -317,115 +357,259 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either MobileNetwork or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.MobileNetwork] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MobileNetwork]: + """Creates or updates a mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to the create or update mobile network operation. + Required. + :type parameters: IO + :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 MobileNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: Union[_models.MobileNetwork, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MobileNetwork]: + """Creates or updates a mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to the create or update mobile network operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.MobileNetwork 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. + :return: An instance of AsyncLROPoller that returns either MobileNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MobileNetwork] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, mobile_network_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.MobileNetwork: """Updates mobile network tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param parameters: Parameters supplied to update mobile network tags. + :param parameters: Parameters supplied to update mobile network tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: MobileNetwork, or the result of cls(response) + :return: MobileNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MobileNetwork: + """Updates mobile network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to update mobile network tags. Required. + :type parameters: IO + :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: MobileNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.MobileNetwork: + """Updates mobile network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to update mobile network tags. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: MobileNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] + api_version: Literal["2022-11-01"] = 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.MobileNetwork] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -433,64 +617,70 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.MobileNetworkListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.MobileNetwork"]: """Lists all the mobile networks in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MobileNetworkListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MobileNetwork or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.MobileNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -498,16 +688,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MobileNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,65 +706,69 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MobileNetworkListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.MobileNetwork"]: """Lists all the mobile networks in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MobileNetworkListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MobileNetwork or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.MobileNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -584,16 +776,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MobileNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -604,139 +794,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks"} # type: ignore - - async def _list_sim_ids_initial( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> _models.SimIdListResult: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimIdListResult] - - - request = build_list_sim_ids_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=self._list_sim_ids_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('SimIdListResult', pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize('SimIdListResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _list_sim_ids_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/listSimIds"} # type: ignore - - - @distributed_trace_async - async def begin_list_sim_ids( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.SimIdListResult]: - """Lists the IDs of all provisioned SIMs in a mobile network. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. - :type mobile_network_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 SimIdListResult or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.SimIdListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimIdListResult] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._list_sim_ids_initial( # type: ignore - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SimIdListResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.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) - - begin_list_sim_ids.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/listSimIds"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_operations.py index de0fdc30dd3c..852ac5d58bb8 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,51 +57,58 @@ 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") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationList]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Gets a list of the operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -94,16 +116,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.MobileNetwork/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.MobileNetwork/operations"} diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_operations.py new file mode 100644 index 000000000000..5047231df3e6 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_operations.py @@ -0,0 +1,562 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._packet_core_control_plane_operations import ( + build_collect_diagnostics_package_request, + build_reinstall_request, + build_rollback_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PacketCoreControlPlaneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mobilenetwork.aio.MobileNetworkManagementClient`'s + :attr:`packet_core_control_plane` 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") + + async def _rollback_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_rollback_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rollback_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _rollback_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + @distributed_trace_async + async def begin_rollback( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Roll back the specified packet core control plane to the previous version, "rollbackVersion". + Multiple consecutive rollbacks are not possible. This action may cause a service outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._rollback_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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_rollback.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + async def _reinstall_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_reinstall_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reinstall_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _reinstall_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + @distributed_trace_async + async def begin_reinstall( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Reinstall the specified packet core control plane. This action will remove any transaction + state from the packet core to return it to a known state. This action will cause a service + outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._reinstall_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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_reinstall.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + async def _collect_diagnostics_package_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreControlPlaneCollectDiagnosticsPackage") + + request = build_collect_diagnostics_package_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._collect_diagnostics_package_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _collect_diagnostics_package_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } + + @overload + async def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: _models.PacketCoreControlPlaneCollectDiagnosticsPackage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage 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. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._collect_diagnostics_package_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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_collect_diagnostics_package.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_versions_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_versions_operations.py index 3b88b07e63f8..ad35134e9b7f 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_versions_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_versions_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,16 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._packet_core_control_plane_versions_operations import build_get_request, build_list_by_resource_group_request -T = TypeVar('T') +from ...operations._packet_core_control_plane_versions_operations import build_get_request, build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PacketCoreControlPlaneVersionsOperations: """ .. warning:: @@ -43,49 +58,47 @@ 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") - @distributed_trace_async - async def get( - self, - version_name: str, - **kwargs: Any - ) -> _models.PacketCoreControlPlaneVersion: + async def get(self, version_name: str, **kwargs: Any) -> _models.PacketCoreControlPlaneVersion: """Gets information about the specified packet core control plane version. - :param version_name: The name of the packet core control plane version. + :param version_name: The name of the packet core control plane version. Required. :type version_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PacketCoreControlPlaneVersion, or the result of cls(response) + :return: PacketCoreControlPlaneVersion or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneVersion] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneVersion] = kwargs.pop("cls", None) - request = build_get_request( version_name=version_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -93,62 +106,69 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreControlPlaneVersion', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlaneVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/{versionName}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/{versionName}"} @distributed_trace - def list_by_resource_group( - self, - **kwargs: Any - ) -> AsyncIterable[_models.PacketCoreControlPlaneVersionListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PacketCoreControlPlaneVersion"]: """Lists all supported packet core control planes versions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreControlPlaneVersionListResult or the - result of cls(response) + :return: An iterator like instance of either PacketCoreControlPlaneVersion or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneVersionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneVersionListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneVersionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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( + + request = build_list_request( api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -156,16 +176,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreControlPlaneVersionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -176,8 +194,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions"} diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py index 698424a452fa..9816e25ef3f8 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._packet_core_control_planes_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_tags_request -T = TypeVar('T') +from ...operations._packet_core_control_planes_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PacketCoreControlPlanesOperations: """ .. warning:: @@ -45,66 +67,65 @@ 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 - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_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. @@ -116,103 +137,103 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any ) -> _models.PacketCoreControlPlane: """Gets information about the specified packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PacketCoreControlPlane, or the result of cls(response) + :return: PacketCoreControlPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlane] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,93 +241,187 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } async def _create_or_update_initial( self, resource_group_name: str, packet_core_control_plane_name: str, - parameters: _models.PacketCoreControlPlane, + parameters: Union[_models.PacketCoreControlPlane, IO], **kwargs: Any ) -> _models.PacketCoreControlPlane: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] - - _json = self._serialize.body(parameters, 'PacketCoreControlPlane') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.PacketCoreControlPlane] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreControlPlane") + + request = build_create_or_update_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, packet_core_control_plane_name: str, parameters: _models.PacketCoreControlPlane, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PacketCoreControlPlane]: """Creates or updates a packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str :param parameters: Parameters supplied to the create or update packet core control plane - operation. + operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane + :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 PacketCoreControlPlane or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PacketCoreControlPlane]: + """Creates or updates a packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the create or update packet core control plane + operation. Required. + :type parameters: IO + :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 PacketCoreControlPlane or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlane, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PacketCoreControlPlane]: + """Creates or updates a packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the create or update packet core control plane + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane 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 @@ -319,95 +434,167 @@ async def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PacketCoreControlPlane] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, packet_core_control_plane_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PacketCoreControlPlane: """Updates packet core control planes tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to update packet core control plane tags. + :param parameters: Parameters supplied to update packet core control plane tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: PacketCoreControlPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PacketCoreControlPlane: + """Updates packet core control planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to update packet core control plane tags. Required. + :type parameters: IO + :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: PacketCoreControlPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.PacketCoreControlPlane: + """Updates packet core control planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to update packet core control plane tags. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: PacketCoreControlPlane, or the result of cls(response) + :return: PacketCoreControlPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] + api_version: Literal["2022-11-01"] = 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.PacketCoreControlPlane] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( resource_group_name=resource_group_name, @@ -416,18 +603,18 @@ async def update_tags( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -435,64 +622,72 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.PacketCoreControlPlaneListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.PacketCoreControlPlane"]: """Lists all the packet core control planes in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreControlPlaneListResult or the result of + :return: An iterator like instance of either PacketCoreControlPlane or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -500,16 +695,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreControlPlaneListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -520,65 +713,73 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes" + } @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PacketCoreControlPlaneListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PacketCoreControlPlane"]: """Lists all the packet core control planes in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreControlPlaneListResult or the result of + :return: An iterator like instance of either PacketCoreControlPlane or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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, - template_url=self.list_by_resource_group.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -586,16 +787,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreControlPlaneListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -606,8 +805,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_data_planes_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_data_planes_operations.py index 150a0210639f..4821bd13e768 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_data_planes_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_data_planes_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._packet_core_data_planes_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_packet_core_control_plane_request, build_update_tags_request -T = TypeVar('T') +from ...operations._packet_core_data_planes_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_packet_core_control_plane_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PacketCoreDataPlanesOperations: """ .. warning:: @@ -45,7 +66,6 @@ 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 self, resource_group_name: str, @@ -54,49 +74,54 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, packet_core_control_plane_name: str, @@ -106,10 +131,11 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the specified packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_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. @@ -121,56 +147,55 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } @distributed_trace_async async def get( @@ -183,46 +208,50 @@ async def get( """Gets information about the specified packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PacketCoreDataPlane, or the result of cls(response) + :return: PacketCoreDataPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreDataPlane] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,39 +259,51 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } async def _create_or_update_initial( self, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, - parameters: _models.PacketCoreDataPlane, + parameters: Union[_models.PacketCoreDataPlane, IO], **kwargs: Any ) -> _models.PacketCoreDataPlane: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] - - _json = self._serialize.body(parameters, 'PacketCoreDataPlane') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.PacketCoreDataPlane] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreDataPlane") + + request = build_create_or_update_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, @@ -270,58 +311,149 @@ async def _create_or_update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, parameters: _models.PacketCoreDataPlane, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PacketCoreDataPlane]: - """Creates or updates a packet core data plane. + """Creates or updates a packet core data plane. Must be created in the same location as its parent + packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str :param parameters: Parameters supplied to the create or update packet core data plane - operation. + operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane + :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 PacketCoreDataPlane or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PacketCoreDataPlane]: + """Creates or updates a packet core data plane. Must be created in the same location as its parent + packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to the create or update packet core data plane + operation. Required. + :type parameters: IO + :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 PacketCoreDataPlane or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: Union[_models.PacketCoreDataPlane, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PacketCoreDataPlane]: + """Creates or updates a packet core data plane. Must be created in the same location as its parent + packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to the create or update packet core data plane + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane 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 @@ -334,99 +466,177 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PacketCoreDataPlane] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PacketCoreDataPlane: """Updates packet core data planes tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param parameters: Parameters supplied to update packet core data plane tags. + :param parameters: Parameters supplied to update packet core data plane tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: PacketCoreDataPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PacketCoreDataPlane: + """Updates packet core data planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to update packet core data plane tags. Required. + :type parameters: IO + :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: PacketCoreDataPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.PacketCoreDataPlane: + """Updates packet core data planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to update packet core data plane tags. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: PacketCoreDataPlane, or the result of cls(response) + :return: PacketCoreDataPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] + api_version: Literal["2022-11-01"] = 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.PacketCoreDataPlane] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( resource_group_name=resource_group_name, @@ -436,18 +646,18 @@ async def update_tags( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -455,74 +665,80 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } @distributed_trace def list_by_packet_core_control_plane( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PacketCoreDataPlaneListResult]: + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PacketCoreDataPlane"]: """Lists all the packet core data planes associated with a packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreDataPlaneListResult or the result of - cls(response) + :return: An iterator like instance of either PacketCoreDataPlane or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlaneListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlaneListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreDataPlaneListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_packet_core_control_plane_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_packet_core_control_plane.metadata['url'], + template_url=self.list_by_packet_core_control_plane.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_packet_core_control_plane_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -530,16 +746,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreDataPlaneListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -550,8 +764,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_packet_core_control_plane.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes"} # type: ignore + list_by_packet_core_control_plane.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_patch.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_patch.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_services_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_services_operations.py index 0a9e1d5d142e..c9655609adc4 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_services_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_services_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._services_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_mobile_network_request, build_update_tags_request -T = TypeVar('T') +from ...operations._services_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_mobile_network_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ServicesOperations: """ .. warning:: @@ -45,72 +66,69 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, service_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - service_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, mobile_network_name: str, service_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_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. @@ -122,109 +140,108 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - mobile_network_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, service_name: str, **kwargs: Any ) -> _models.Service: """Gets information about the specified service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Service, or the result of cls(response) + :return: Service or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Service - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Service] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -232,39 +249,51 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } async def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, service_name: str, - parameters: _models.Service, + parameters: Union[_models.Service, IO], **kwargs: Any ) -> _models.Service: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] - - _json = self._serialize.body(parameters, 'Service') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.Service] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Service") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, @@ -272,58 +301,148 @@ async def _create_or_update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, service_name: str, parameters: _models.Service, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Service]: - """Creates or updates a service. + """Creates or updates a service. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_name: str - :param parameters: Parameters supplied to the create or update service operation. + :param parameters: Parameters supplied to the create or update service operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Service + :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 Service or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Service] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Service]: + """Creates or updates a service. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to the create or update service operation. Required. + :type parameters: IO + :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 Service or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Service] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: Union[_models.Service, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Service]: + """Creates or updates a service. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to the create or update service operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Service 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 @@ -335,121 +454,201 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either Service or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Service] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Service] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, mobile_network_name: str, service_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Updates service tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_name: str - :param parameters: Parameters supplied to update service tags. + :param parameters: Parameters supplied to update service tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: Service or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Service + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Service: + """Updates service tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to update service tags. Required. + :type parameters: IO + :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: Service or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Service + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.Service: + """Updates service tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to update service tags. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: Service, or the result of cls(response) + :return: Service or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Service - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] + api_version: Literal["2022-11-01"] = 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.Service] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -457,73 +656,79 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ServiceListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Service"]: """Gets all the services in a mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.ServiceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Service or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.Service] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ServiceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -531,16 +736,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -551,8 +754,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_groups_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_groups_operations.py index e0fc7c38f1e1..4c29abbdaa5e 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_groups_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_groups_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._sim_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_tags_request -T = TypeVar('T') +from ...operations._sim_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SimGroupsOperations: """ .. warning:: @@ -45,66 +67,63 @@ 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 - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any + self, resource_group_name: str, sim_group_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, sim_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the specified SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_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. @@ -116,103 +135,101 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, sim_group_name=sim_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any - ) -> _models.SimGroup: + async def get(self, resource_group_name: str, sim_group_name: str, **kwargs: Any) -> _models.SimGroup: """Gets information about the specified SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimGroup, or the result of cls(response) + :return: SimGroup or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimGroup] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,92 +237,108 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } async def _create_or_update_initial( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.SimGroup, - **kwargs: Any + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimGroup, IO], **kwargs: Any ) -> _models.SimGroup: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] - - _json = self._serialize.body(parameters, 'SimGroup') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.SimGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimGroup") + + request = build_create_or_update_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, sim_group_name: str, parameters: _models.SimGroup, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SimGroup]: """Creates or updates a SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param parameters: Parameters supplied to the create or update SIM group operation. + :param parameters: Parameters supplied to the create or update SIM group operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.SimGroup + :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 @@ -317,115 +350,250 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either SimGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.SimGroup] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SimGroup]: + """Creates or updates a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the create or update SIM group operation. Required. + :type parameters: IO + :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 SimGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimGroup, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.SimGroup]: + """Creates or updates a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the create or update SIM group operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimGroup 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. + :return: An instance of AsyncLROPoller that returns either SimGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SimGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, sim_group_name=sim_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/simGroups/{simGroupName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, sim_group_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SimGroup: """Updates SIM group tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param parameters: Parameters supplied to update SIM group tags. + :param parameters: Parameters supplied to update SIM group tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: SimGroup or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SimGroup: + """Updates SIM group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to update SIM group tags. Required. + :type parameters: IO + :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: SimGroup or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + ) -> _models.SimGroup: + """Updates SIM group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to update SIM group tags. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: SimGroup, or the result of cls(response) + :return: SimGroup or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] + api_version: Literal["2022-11-01"] = 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.SimGroup] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -433,63 +601,70 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SimGroupListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SimGroup"]: """Gets all the SIM groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SimGroupListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SimGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SimGroup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroupListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimGroupListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -497,16 +672,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SimGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -517,64 +690,69 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/simGroups"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/simGroups" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SimGroupListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SimGroup"]: """Gets all the SIM groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SimGroupListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SimGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SimGroup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroupListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimGroupListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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, - template_url=self.list_by_resource_group.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -582,16 +760,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SimGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -602,8 +778,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_operations.py new file mode 100644 index 000000000000..9e3fec128b01 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_operations.py @@ -0,0 +1,742 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._sim_operations import ( + build_bulk_delete_request, + build_bulk_upload_encrypted_request, + build_bulk_upload_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SimOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mobilenetwork.aio.MobileNetworkManagementClient`'s + :attr:`sim` 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") + + async def _bulk_upload_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimUploadList") + + request = build_bulk_upload_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + @overload + async def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_bulk_upload( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList 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. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._bulk_upload_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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_bulk_upload.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + async def _bulk_delete_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimDeleteList") + + request = build_bulk_delete_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + @overload + async def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimDeleteList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_bulk_delete( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList 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. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._bulk_delete_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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_bulk_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + async def _bulk_upload_encrypted_initial( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "EncryptedSimUploadList") + + request = build_bulk_upload_encrypted_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_encrypted_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_encrypted_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } + + @overload + async def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.EncryptedSimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList 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. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._bulk_upload_encrypted_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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_bulk_upload_encrypted.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_policies_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_policies_operations.py index f321b6a0fa09..70af13022614 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_policies_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_policies_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._sim_policies_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_mobile_network_request, build_update_tags_request -T = TypeVar('T') +from ...operations._sim_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_mobile_network_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SimPoliciesOperations: """ .. warning:: @@ -45,71 +66,68 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified SIM policy. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_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. @@ -121,108 +139,107 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, **kwargs: Any ) -> _models.SimPolicy: """Gets information about the specified SIM policy. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimPolicy, or the result of cls(response) + :return: SimPolicy or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimPolicy] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,39 +247,51 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } async def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, - parameters: _models.SimPolicy, + parameters: Union[_models.SimPolicy, IO], **kwargs: Any ) -> _models.SimPolicy: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] - - _json = self._serialize.body(parameters, 'SimPolicy') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.SimPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimPolicy") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, @@ -270,57 +299,145 @@ async def _create_or_update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, parameters: _models.SimPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SimPolicy]: - """Creates or updates a SIM policy. + """Creates or updates a SIM policy. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_name: str - :param parameters: Parameters supplied to the create or update SIM policy operation. + :param parameters: Parameters supplied to the create or update SIM policy operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.SimPolicy + :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 SimPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.SimPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SimPolicy]: + """Creates or updates a SIM policy. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to the create or update SIM policy operation. Required. + :type parameters: IO + :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 SimPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.SimPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: Union[_models.SimPolicy, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.SimPolicy]: + """Creates or updates a SIM policy. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to the create or update SIM policy operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimPolicy 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 @@ -332,120 +449,198 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either SimPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.SimPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SimPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SimPolicy: """Updates SIM policy tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_name: str - :param parameters: Parameters supplied to update SIM policy tags. + :param parameters: Parameters supplied to update SIM policy tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: SimPolicy or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SimPolicy: + """Updates SIM policy tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to update SIM policy tags. Required. + :type parameters: IO + :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: SimPolicy or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.SimPolicy: + """Updates SIM policy tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to update SIM policy tags. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: SimPolicy, or the result of cls(response) + :return: SimPolicy or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] + api_version: Literal["2022-11-01"] = 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.SimPolicy] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -453,73 +648,79 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SimPolicyListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SimPolicy"]: """Gets all the SIM policies in a mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SimPolicyListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SimPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SimPolicy or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SimPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicyListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimPolicyListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -527,16 +728,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SimPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -547,8 +746,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py index e62d5c4d7226..f8f959f25851 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._sims_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_sim_group_request -T = TypeVar('T') +from ...operations._sims_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_group_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SimsOperations: """ .. warning:: @@ -45,71 +65,68 @@ 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 - self, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any + self, resource_group_name: str, sim_group_name: str, sim_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, sim_group_name: str, sim_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified SIM. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param sim_name: The name of the SIM. + :param sim_name: The name of the SIM. Required. :type sim_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. @@ -121,108 +138,105 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any - ) -> _models.Sim: + async def get(self, resource_group_name: str, sim_group_name: str, sim_name: str, **kwargs: Any) -> _models.Sim: """Gets information about the specified SIM. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param sim_name: The name of the SIM. + :param sim_name: The name of the SIM. Required. :type sim_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Sim, or the result of cls(response) + :return: Sim or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Sim - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Sim] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Sim] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,97 +244,117 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } async def _create_or_update_initial( self, resource_group_name: str, sim_group_name: str, sim_name: str, - parameters: _models.Sim, + parameters: Union[_models.Sim, IO], **kwargs: Any ) -> _models.Sim: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Sim] - - _json = self._serialize.body(parameters, 'Sim') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.Sim] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Sim") + + request = build_create_or_update_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, sim_group_name: str, sim_name: str, parameters: _models.Sim, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Sim]: """Creates or updates a SIM. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param sim_name: The name of the SIM. + :param sim_name: The name of the SIM. Required. :type sim_name: str - :param parameters: Parameters supplied to the create or update SIM operation. + :param parameters: Parameters supplied to the create or update SIM operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Sim + :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 @@ -331,118 +365,199 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Sim or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Sim] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + sim_group_name: str, + sim_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Sim]: + """Creates or updates a SIM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param sim_name: The name of the SIM. Required. + :type sim_name: str + :param parameters: Parameters supplied to the create or update SIM operation. Required. + :type parameters: IO + :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 Sim or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Sim] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + sim_group_name: str, + sim_name: str, + parameters: Union[_models.Sim, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Sim]: + """Creates or updates a SIM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param sim_name: The name of the SIM. Required. + :type sim_name: str + :param parameters: Parameters supplied to the create or update SIM operation. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Sim 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. + :return: An instance of AsyncLROPoller that returns either Sim or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Sim] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Sim] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Sim] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } @distributed_trace - def list_by_sim_group( - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SimListResult]: + def list_by_group( + self, resource_group_name: str, sim_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Sim"]: """Gets all the SIMs in a SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_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 SimListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SimListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sim or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.Sim] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_list_by_sim_group_request( + + request = build_list_by_group_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sim_group.metadata['url'], + template_url=self.list_by_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_sim_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - sim_group_name=sim_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -450,16 +565,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SimListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -470,8 +583,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_sim_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims"} # type: ignore + list_by_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sites_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sites_operations.py index b10ba2880a8d..14fcb844264e 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sites_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sites_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._sites_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_mobile_network_request, build_update_tags_request -T = TypeVar('T') +from ...operations._sites_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_mobile_network_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SitesOperations: """ .. warning:: @@ -45,71 +66,69 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, site_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, mobile_network_name: str, site_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes the specified mobile network site. + """Deletes the specified mobile network site. This will also delete any network functions that are + a part of this site. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_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. @@ -121,108 +140,107 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, site_name: str, **kwargs: Any ) -> _models.Site: """Gets information about the specified mobile network site. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Site, or the result of cls(response) + :return: Site or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Site - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,97 +248,197 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } async def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, site_name: str, - parameters: _models.Site, + parameters: Union[_models.Site, IO], **kwargs: Any ) -> _models.Site: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] - - _json = self._serialize.body(parameters, 'Site') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.Site] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Site") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, site_name: str, parameters: _models.Site, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Site]: - """Creates or updates a mobile network site. + """Creates or updates a mobile network site. Must be created in the same location as its parent + mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_name: str :param parameters: Parameters supplied to the create or update mobile network site operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Site + :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 Site or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Site]: + """Creates or updates a mobile network site. Must be created in the same location as its parent + mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update mobile network site operation. + Required. + :type parameters: IO + :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 Site or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: Union[_models.Site, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Site]: + """Creates or updates a mobile network site. Must be created in the same location as its parent + mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update mobile network site operation. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Site 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 @@ -331,120 +449,198 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Site or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Site] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, mobile_network_name: str, site_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Site: """Updates site tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_name: str - :param parameters: Parameters supplied to update network site tags. + :param parameters: Parameters supplied to update network site tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: Site or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Site: + """Updates site tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: IO + :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: Site or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.Site: + """Updates site tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: Site, or the result of cls(response) + :return: Site or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Site - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] + api_version: Literal["2022-11-01"] = 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.Site] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,73 +648,79 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SiteListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Site"]: """Lists all sites in the mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SiteListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SiteListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Site or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SiteListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SiteListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -526,16 +728,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SiteListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +746,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_slices_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_slices_operations.py index 20ab90fb32c4..21837f313307 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_slices_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_slices_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._slices_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_mobile_network_request, build_update_tags_request -T = TypeVar('T') +from ...operations._slices_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_mobile_network_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SlicesOperations: """ .. warning:: @@ -45,71 +66,68 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, slice_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, mobile_network_name: str, slice_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified network slice. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_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. @@ -121,108 +139,107 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, slice_name: str, **kwargs: Any ) -> _models.Slice: """Gets information about the specified network slice. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Slice, or the result of cls(response) + :return: Slice or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Slice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Slice] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,97 +247,159 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } async def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, slice_name: str, - parameters: _models.Slice, + parameters: Union[_models.Slice, IO], **kwargs: Any ) -> _models.Slice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] - - _json = self._serialize.body(parameters, 'Slice') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.Slice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Slice") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, slice_name: str, parameters: _models.Slice, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Slice]: - """Creates or updates a network slice. + """Creates or updates a network slice. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_name: str :param parameters: Parameters supplied to the create or update network slice operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Slice + :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 Slice or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Slice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Slice]: + """Creates or updates a network slice. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to the create or update network slice operation. + Required. + :type parameters: IO + :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 @@ -331,120 +410,236 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Slice or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Slice] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: Union[_models.Slice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Slice]: + """Creates or updates a network slice. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to the create or update network slice operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Slice 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. + :return: An instance of AsyncLROPoller that returns either Slice or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.Slice] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Slice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, mobile_network_name: str, slice_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Slice: """Updates slice tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_name: str - :param parameters: Parameters supplied to update network slice tags. + :param parameters: Parameters supplied to update network slice tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: Slice, or the result of cls(response) + :return: Slice or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Slice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Slice: + """Updates slice tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to update network slice tags. Required. + :type parameters: IO + :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: Slice or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Slice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.Slice: + """Updates slice tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to update network slice tags. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: Slice or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Slice + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] + api_version: Literal["2022-11-01"] = 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.Slice] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,73 +647,79 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SliceListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Slice"]: """Lists all slices in the mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SliceListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.SliceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Slice or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mobilenetwork.models.Slice] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SliceListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SliceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -526,16 +727,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SliceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +745,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/__init__.py index c83ea0ca9e30..9b9e5b6f47a1 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/__init__.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/__init__.py @@ -8,21 +8,29 @@ from ._models_py3 import Ambr from ._models_py3 import Arp +from ._models_py3 import AsyncOperationId +from ._models_py3 import AsyncOperationStatus from ._models_py3 import AttachedDataNetwork from ._models_py3 import AttachedDataNetworkListResult from ._models_py3 import AttachedDataNetworkResourceId from ._models_py3 import AzureStackEdgeDeviceResourceId +from ._models_py3 import AzureStackHCIClusterResourceId +from ._models_py3 import CertificateProvisioning +from ._models_py3 import CommonSimPropertiesFormat from ._models_py3 import ConnectedClusterResourceId from ._models_py3 import CustomLocationResourceId from ._models_py3 import DataNetwork from ._models_py3 import DataNetworkConfiguration from ._models_py3 import DataNetworkListResult from ._models_py3 import DataNetworkResourceId +from ._models_py3 import EncryptedSimPropertiesFormat +from ._models_py3 import EncryptedSimUploadList from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse +from ._models_py3 import HttpsServerCertificate +from ._models_py3 import Installation from ._models_py3 import InterfaceProperties -from ._models_py3 import KeyVaultCertificate from ._models_py3 import KeyVaultKey from ._models_py3 import LocalDiagnosticsAccessConfiguration from ._models_py3 import ManagedServiceIdentity @@ -34,6 +42,7 @@ from ._models_py3 import OperationDisplay from ._models_py3 import OperationList from ._models_py3 import PacketCoreControlPlane +from ._models_py3 import PacketCoreControlPlaneCollectDiagnosticsPackage from ._models_py3 import PacketCoreControlPlaneListResult from ._models_py3 import PacketCoreControlPlaneVersion from ._models_py3 import PacketCoreControlPlaneVersionListResult @@ -42,6 +51,7 @@ from ._models_py3 import PccRuleConfiguration from ._models_py3 import PccRuleQosPolicy from ._models_py3 import PinholeTimeouts +from ._models_py3 import Platform from ._models_py3 import PlatformConfiguration from ._models_py3 import PlmnId from ._models_py3 import PortRange @@ -54,18 +64,23 @@ from ._models_py3 import ServiceListResult from ._models_py3 import ServiceResourceId from ._models_py3 import Sim +from ._models_py3 import SimDeleteList from ._models_py3 import SimGroup from ._models_py3 import SimGroupListResult from ._models_py3 import SimGroupResourceId -from ._models_py3 import SimIdListResult from ._models_py3 import SimListResult +from ._models_py3 import SimNameAndEncryptedProperties +from ._models_py3 import SimNameAndProperties from ._models_py3 import SimPolicy from ._models_py3 import SimPolicyListResult from ._models_py3 import SimPolicyResourceId +from ._models_py3 import SimPropertiesFormat from ._models_py3 import SimStaticIpProperties from ._models_py3 import SimStaticIpPropertiesStaticIp +from ._models_py3 import SimUploadList from ._models_py3 import Site from ._models_py3 import SiteListResult +from ._models_py3 import SiteResourceId from ._models_py3 import Slice from ._models_py3 import SliceConfiguration from ._models_py3 import SliceListResult @@ -77,113 +92,136 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentity - -from ._mobile_network_management_client_enums import ( - BillingSku, - CoreNetworkType, - CreatedByType, - ManagedServiceIdentityType, - NaptEnabled, - PduSessionType, - PlatformType, - PreemptionCapability, - PreemptionVulnerability, - ProvisioningState, - RecommendedVersion, - SdfDirection, - SimState, - TrafficControlPermission, - VersionState, -) +from ._mobile_network_management_client_enums import AuthenticationType +from ._mobile_network_management_client_enums import BillingSku +from ._mobile_network_management_client_enums import CertificateProvisioningState +from ._mobile_network_management_client_enums import CoreNetworkType +from ._mobile_network_management_client_enums import CreatedByType +from ._mobile_network_management_client_enums import InstallationState +from ._mobile_network_management_client_enums import ManagedServiceIdentityType +from ._mobile_network_management_client_enums import NaptEnabled +from ._mobile_network_management_client_enums import ObsoleteVersion +from ._mobile_network_management_client_enums import PduSessionType +from ._mobile_network_management_client_enums import PlatformType +from ._mobile_network_management_client_enums import PreemptionCapability +from ._mobile_network_management_client_enums import PreemptionVulnerability +from ._mobile_network_management_client_enums import ProvisioningState +from ._mobile_network_management_client_enums import RecommendedVersion +from ._mobile_network_management_client_enums import SdfDirection +from ._mobile_network_management_client_enums import SimState +from ._mobile_network_management_client_enums import SiteProvisioningState +from ._mobile_network_management_client_enums import TrafficControlPermission +from ._mobile_network_management_client_enums import VersionState from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Ambr', - 'Arp', - 'AttachedDataNetwork', - 'AttachedDataNetworkListResult', - 'AttachedDataNetworkResourceId', - 'AzureStackEdgeDeviceResourceId', - 'ConnectedClusterResourceId', - 'CustomLocationResourceId', - 'DataNetwork', - 'DataNetworkConfiguration', - 'DataNetworkListResult', - 'DataNetworkResourceId', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'InterfaceProperties', - 'KeyVaultCertificate', - 'KeyVaultKey', - 'LocalDiagnosticsAccessConfiguration', - 'ManagedServiceIdentity', - 'MobileNetwork', - 'MobileNetworkListResult', - 'MobileNetworkResourceId', - 'NaptConfiguration', - 'Operation', - 'OperationDisplay', - 'OperationList', - 'PacketCoreControlPlane', - 'PacketCoreControlPlaneListResult', - 'PacketCoreControlPlaneVersion', - 'PacketCoreControlPlaneVersionListResult', - 'PacketCoreDataPlane', - 'PacketCoreDataPlaneListResult', - 'PccRuleConfiguration', - 'PccRuleQosPolicy', - 'PinholeTimeouts', - 'PlatformConfiguration', - 'PlmnId', - 'PortRange', - 'PortReuseHoldTimes', - 'ProxyResource', - 'QosPolicy', - 'Resource', - 'Service', - 'ServiceDataFlowTemplate', - 'ServiceListResult', - 'ServiceResourceId', - 'Sim', - 'SimGroup', - 'SimGroupListResult', - 'SimGroupResourceId', - 'SimIdListResult', - 'SimListResult', - 'SimPolicy', - 'SimPolicyListResult', - 'SimPolicyResourceId', - 'SimStaticIpProperties', - 'SimStaticIpPropertiesStaticIp', - 'Site', - 'SiteListResult', - 'Slice', - 'SliceConfiguration', - 'SliceListResult', - 'SliceResourceId', - 'Snssai', - 'SubResource', - 'SystemData', - 'TagsObject', - 'TrackedResource', - 'UserAssignedIdentity', - 'BillingSku', - 'CoreNetworkType', - 'CreatedByType', - 'ManagedServiceIdentityType', - 'NaptEnabled', - 'PduSessionType', - 'PlatformType', - 'PreemptionCapability', - 'PreemptionVulnerability', - 'ProvisioningState', - 'RecommendedVersion', - 'SdfDirection', - 'SimState', - 'TrafficControlPermission', - 'VersionState', + "Ambr", + "Arp", + "AsyncOperationId", + "AsyncOperationStatus", + "AttachedDataNetwork", + "AttachedDataNetworkListResult", + "AttachedDataNetworkResourceId", + "AzureStackEdgeDeviceResourceId", + "AzureStackHCIClusterResourceId", + "CertificateProvisioning", + "CommonSimPropertiesFormat", + "ConnectedClusterResourceId", + "CustomLocationResourceId", + "DataNetwork", + "DataNetworkConfiguration", + "DataNetworkListResult", + "DataNetworkResourceId", + "EncryptedSimPropertiesFormat", + "EncryptedSimUploadList", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "HttpsServerCertificate", + "Installation", + "InterfaceProperties", + "KeyVaultKey", + "LocalDiagnosticsAccessConfiguration", + "ManagedServiceIdentity", + "MobileNetwork", + "MobileNetworkListResult", + "MobileNetworkResourceId", + "NaptConfiguration", + "Operation", + "OperationDisplay", + "OperationList", + "PacketCoreControlPlane", + "PacketCoreControlPlaneCollectDiagnosticsPackage", + "PacketCoreControlPlaneListResult", + "PacketCoreControlPlaneVersion", + "PacketCoreControlPlaneVersionListResult", + "PacketCoreDataPlane", + "PacketCoreDataPlaneListResult", + "PccRuleConfiguration", + "PccRuleQosPolicy", + "PinholeTimeouts", + "Platform", + "PlatformConfiguration", + "PlmnId", + "PortRange", + "PortReuseHoldTimes", + "ProxyResource", + "QosPolicy", + "Resource", + "Service", + "ServiceDataFlowTemplate", + "ServiceListResult", + "ServiceResourceId", + "Sim", + "SimDeleteList", + "SimGroup", + "SimGroupListResult", + "SimGroupResourceId", + "SimListResult", + "SimNameAndEncryptedProperties", + "SimNameAndProperties", + "SimPolicy", + "SimPolicyListResult", + "SimPolicyResourceId", + "SimPropertiesFormat", + "SimStaticIpProperties", + "SimStaticIpPropertiesStaticIp", + "SimUploadList", + "Site", + "SiteListResult", + "SiteResourceId", + "Slice", + "SliceConfiguration", + "SliceListResult", + "SliceResourceId", + "Snssai", + "SubResource", + "SystemData", + "TagsObject", + "TrackedResource", + "UserAssignedIdentity", + "AuthenticationType", + "BillingSku", + "CertificateProvisioningState", + "CoreNetworkType", + "CreatedByType", + "InstallationState", + "ManagedServiceIdentityType", + "NaptEnabled", + "ObsoleteVersion", + "PduSessionType", + "PlatformType", + "PreemptionCapability", + "PreemptionVulnerability", + "ProvisioningState", + "RecommendedVersion", + "SdfDirection", + "SimState", + "SiteProvisioningState", + "TrafficControlPermission", + "VersionState", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_mobile_network_management_client_enums.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_mobile_network_management_client_enums.py index 4f6a0c6b9b35..5e10313e04f9 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_mobile_network_management_client_enums.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_mobile_network_management_client_enums.py @@ -10,44 +10,88 @@ from azure.core import CaseInsensitiveEnumMeta +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """How to authenticate users who access local diagnostics APIs.""" + + #: Use AAD SSO to authenticate the user (this requires internet access). + AAD = "AAD" + #: Use locally stored passwords to authenticate the user. + PASSWORD = "Password" + + class BillingSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU of the packet core control plane resource. The SKU list may change over time when a new SKU gets added or an exiting SKU gets removed. """ - #: Evaluation package plan. - EVALUATION_PACKAGE = "EvaluationPackage" - #: Flagship starter package plan. - FLAGSHIP_STARTER_PACKAGE = "FlagshipStarterPackage" - #: Edge site 2Gbps plan. - EDGE_SITE2_GBPS = "EdgeSite2GBPS" - #: Edge site 3Gbps plan. - EDGE_SITE3_GBPS = "EdgeSite3GBPS" - #: Edge site 4Gbps plan. - EDGE_SITE4_GBPS = "EdgeSite4GBPS" - #: Medium package plan. - MEDIUM_PACKAGE = "MediumPackage" - #: Large package plan. - LARGE_PACKAGE = "LargePackage" + #: 100 Mbps, 20 active SIMs plan + G0 = "G0" + #: 1 Gbps, 100 active SIMs plan + G1 = "G1" + #: 2 Gbps, 200 active SIMs plan + G2 = "G2" + #: 3 Gbps, 300 active SIMs plan + G3 = "G3" + #: 4 Gbps, 400 active SIMs plan + G4 = "G4" + #: 5 Gbps, 500 active SIMs plan + G5 = "G5" + #: 10 Gbps, 1000 active SIMs plan + G10 = "G10" + + +class CertificateProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The certificate's provisioning state.""" + + #: The certificate has not been provisioned. + NOT_PROVISIONED = "NotProvisioned" + #: The certificate has been provisioned. + PROVISIONED = "Provisioned" + #: The certificate failed to be provisioned. The "reason" property explains why. + FAILED = "Failed" + class CoreNetworkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The core network technology generation (5G core or EPC / 4G core). - """ + """The core network technology generation (5G core or EPC / 4G core).""" - #: 5G core. + #: 5G core FIVE_GC = "5GC" - #: EPC / 4G core. + #: EPC / 4G core EPC = "EPC" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + +class InstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The installation state of the packet core.""" + + #: The packet core is uninstalled. + UNINSTALLED = "Uninstalled" + #: The packet core is installing. + INSTALLING = "Installing" + #: The packet core is installed. + INSTALLED = "Installed" + #: The packet core is updating its configuration. + UPDATING = "Updating" + #: The packet core is upgrading to a different software version. + UPGRADING = "Upgrading" + #: The packet core is uninstalling. + UNINSTALLING = "Uninstalling" + #: The packet core is reinstalling. + REINSTALLING = "Reinstalling" + #: The packet core is rolling back to its previous version. + ROLLING_BACK = "RollingBack" + #: The packet core is in failed state. + FAILED = "Failed" + + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). @@ -58,55 +102,63 @@ class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class NaptEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether network address and port translation is enabled. - """ + """Whether network address and port translation is enabled.""" - #: NAPT is enabled. + #: NAPT is enabled ENABLED = "Enabled" - #: NAPT is disabled. + #: NAPT is disabled DISABLED = "Disabled" + +class ObsoleteVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether this version is obsolete.""" + + #: This version is obsolete for use in new packet core control plane deployments. + OBSOLETE = "Obsolete" + #: This version is not obsolete for use in new packet core control plane deployments. + NOT_OBSOLETE = "NotObsolete" + + class PduSessionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PDU session type (IPv4/IPv6). - """ + """PDU session type (IPv4/IPv6).""" I_PV4 = "IPv4" I_PV6 = "IPv6" + class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The platform type where packet core is deployed. The contents of this enum can change. - """ + """The platform type where packet core is deployed. The contents of this enum can change.""" #: If this option is chosen, you must set one of "azureStackEdgeDevice", "connectedCluster" or - #: "customLocation". If multiple are set then "customLocation" will take precedence over - #: "connectedCluster" which takes precedence over "azureStackEdgeDevice". + #: "customLocation". If multiple are set, they must be consistent with each other. AKS_HCI = "AKS-HCI" - #: If this option is chosen, you must set one of "connectedCluster" or "customLocation". If - #: multiple are set then "customLocation" will take precedence over "connectedCluster". - BASE_VM = "BaseVM" + #: If this option is chosen, you must set one of "azureStackHciCluster", "connectedCluster" or + #: "customLocation". If multiple are set, they must be consistent with each other. + THREE_P_AZURE_STACK_HCI = "3P-AZURE-STACK-HCI" + class PreemptionCapability(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Preemption capability. - """ + """Preemption capability.""" - #: Cannot preempt. + #: Cannot preempt NOT_PREEMPT = "NotPreempt" - #: May preempt. + #: May preempt MAY_PREEMPT = "MayPreempt" + class PreemptionVulnerability(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Preemption vulnerability. - """ + """Preemption vulnerability.""" - #: Cannot be preempted. + #: Cannot be preempted NOT_PREEMPTABLE = "NotPreemptable" - #: May be preempted. + #: May be preempted PREEMPTABLE = "Preemptable" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" UNKNOWN = "Unknown" SUCCEEDED = "Succeeded" @@ -116,6 +168,7 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" DELETED = "Deleted" + class RecommendedVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates whether this is the recommended version to use for new packet core control plane deployments. @@ -126,9 +179,9 @@ class RecommendedVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: This is not the recommended version to use for new packet core control plane deployments. NOT_RECOMMENDED = "NotRecommended" + class SdfDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Service data flow direction. - """ + """Service data flow direction.""" #: Traffic flowing from the UE to the data network. UPLINK = "Uplink" @@ -137,9 +190,9 @@ class SdfDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Traffic flowing both to and from the UE. BIDIRECTIONAL = "Bidirectional" + class SimState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the SIM resource. - """ + """The state of the SIM resource.""" #: The SIM is disabled because not all configuration required for enabling is present. DISABLED = "Disabled" @@ -148,18 +201,35 @@ class SimState(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The SIM cannot be enabled because some of the associated configuration is invalid. INVALID = "Invalid" + +class SiteProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of a resource e.g. SIM/SIM policy on a site.""" + + #: The resource should not be provisioned on this site. + NOT_APPLICABLE = "NotApplicable" + #: The resource is being added to this site. + ADDING = "Adding" + #: The resource is being updated on this site. + UPDATING = "Updating" + #: The resource is being deleted from this site. + DELETING = "Deleting" + #: The resource is provisioned on this site. + PROVISIONED = "Provisioned" + #: The resource failed to be provisioned on this site. + FAILED = "Failed" + + class TrafficControlPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Traffic control permission. - """ + """Traffic control permission.""" #: Traffic matching this rule is allowed to flow. ENABLED = "Enabled" #: Traffic matching this rule is not allowed to flow. BLOCKED = "Blocked" + class VersionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of this packet core control plane version. - """ + """The state of this packet core control plane version.""" #: The state of this version is unknown. UNKNOWN = "Unknown" diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_models_py3.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_models_py3.py index edb17b2b1b3e..0f4ee43562ce 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_models_py3.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,80 +8,80 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Ambr(msrest.serialization.Model): +class Ambr(_serialization.Model): """Aggregate maximum bit rate. All required parameters must be populated in order to send to Azure. - :ivar uplink: Required. Uplink bit rate. + :ivar uplink: Uplink bit rate. Required. :vartype uplink: str - :ivar downlink: Required. Downlink bit rate. + :ivar downlink: Downlink bit rate. Required. :vartype downlink: str """ _validation = { - 'uplink': {'required': True, 'pattern': r'^\d+(\.\d+)? (bps|Kbps|Mbps|Gbps|Tbps)$'}, - 'downlink': {'required': True, 'pattern': r'^\d+(\.\d+)? (bps|Kbps|Mbps|Gbps|Tbps)$'}, + "uplink": {"required": True, "pattern": r"^\d+(\.\d+)? (bps|Kbps|Mbps|Gbps|Tbps)$"}, + "downlink": {"required": True, "pattern": r"^\d+(\.\d+)? (bps|Kbps|Mbps|Gbps|Tbps)$"}, } _attribute_map = { - 'uplink': {'key': 'uplink', 'type': 'str'}, - 'downlink': {'key': 'downlink', 'type': 'str'}, + "uplink": {"key": "uplink", "type": "str"}, + "downlink": {"key": "downlink", "type": "str"}, } - def __init__( - self, - *, - uplink: str, - downlink: str, - **kwargs - ): + def __init__(self, *, uplink: str, downlink: str, **kwargs): """ - :keyword uplink: Required. Uplink bit rate. + :keyword uplink: Uplink bit rate. Required. :paramtype uplink: str - :keyword downlink: Required. Downlink bit rate. + :keyword downlink: Downlink bit rate. Required. :paramtype downlink: str """ - super(Ambr, self).__init__(**kwargs) + super().__init__(**kwargs) self.uplink = uplink self.downlink = downlink -class Arp(msrest.serialization.Model): +class Arp(_serialization.Model): """Allocation and Retention Priority (ARP) parameters. All required parameters must be populated in order to send to Azure. - :ivar priority_level: Required. ARP priority level. + :ivar priority_level: ARP priority level. Required. :vartype priority_level: int - :ivar preempt_cap: Required. ARP preemption capability. Known values are: "NotPreempt", + :ivar preempt_cap: ARP preemption capability. Required. Known values are: "NotPreempt" and "MayPreempt". :vartype preempt_cap: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability - :ivar preempt_vuln: Required. ARP preemption vulnerability. Known values are: "NotPreemptable", - "Preemptable". + :ivar preempt_vuln: ARP preemption vulnerability. Required. Known values are: "NotPreemptable" + and "Preemptable". :vartype preempt_vuln: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability """ _validation = { - 'priority_level': {'required': True, 'maximum': 15, 'minimum': 1}, - 'preempt_cap': {'required': True}, - 'preempt_vuln': {'required': True}, + "priority_level": {"required": True, "maximum": 15, "minimum": 1}, + "preempt_cap": {"required": True}, + "preempt_vuln": {"required": True}, } _attribute_map = { - 'priority_level': {'key': 'priorityLevel', 'type': 'int'}, - 'preempt_cap': {'key': 'preemptCap', 'type': 'str'}, - 'preempt_vuln': {'key': 'preemptVuln', 'type': 'str'}, + "priority_level": {"key": "priorityLevel", "type": "int"}, + "preempt_cap": {"key": "preemptCap", "type": "str"}, + "preempt_vuln": {"key": "preemptVuln", "type": "str"}, } def __init__( @@ -92,22 +93,141 @@ def __init__( **kwargs ): """ - :keyword priority_level: Required. ARP priority level. + :keyword priority_level: ARP priority level. Required. :paramtype priority_level: int - :keyword preempt_cap: Required. ARP preemption capability. Known values are: "NotPreempt", + :keyword preempt_cap: ARP preemption capability. Required. Known values are: "NotPreempt" and "MayPreempt". :paramtype preempt_cap: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability - :keyword preempt_vuln: Required. ARP preemption vulnerability. Known values are: - "NotPreemptable", "Preemptable". + :keyword preempt_vuln: ARP preemption vulnerability. Required. Known values are: + "NotPreemptable" and "Preemptable". :paramtype preempt_vuln: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability """ - super(Arp, self).__init__(**kwargs) + super().__init__(**kwargs) self.priority_level = priority_level self.preempt_cap = preempt_cap self.preempt_vuln = preempt_vuln -class Resource(msrest.serialization.Model): +class AsyncOperationId(_serialization.Model): + """Reference to an Azure Async Operation ID. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure Async Operation ID. Required. + :vartype id: str + """ + + _validation = { + "id": { + "required": True, + "pattern": r"^/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[^/?#]+/[lL][oO][cC][aA][tT][iI][oO][nN][sS]/[^/?#]+/[oO][pP][eE][rR][aA][tT][iI][oO][nN][sS][tT][aA][tT][uU][sS][eE][sS]/[^/?#]+$", + }, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: Azure Async Operation ID. Required. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class AsyncOperationStatus(_serialization.Model): + """The current status of an async operation. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: The operation status. Required. + :vartype status: str + :ivar resource_id: Fully qualified ID for the resource that this async operation status relates + to. + :vartype resource_id: str + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: Percentage of the operation that is complete. + :vartype percent_complete: float + :ivar properties: Properties returned by the resource provider on a successful operation. + :vartype properties: JSON + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.mobilenetwork.models.ErrorDetail + """ + + _validation = { + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "properties": {"key": "properties", "type": "object"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + resource_id: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + percent_complete: Optional[float] = None, + properties: Optional[JSON] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: The operation status. Required. + :paramtype status: str + :keyword resource_id: Fully qualified ID for the resource that this async operation status + relates to. + :paramtype resource_id: str + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword percent_complete: Percentage of the operation that is complete. + :paramtype percent_complete: float + :keyword properties: Properties returned by the resource provider on a successful operation. + :paramtype properties: JSON + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.mobilenetwork.models.ErrorDetail + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.resource_id = resource_id + self.start_time = start_time + self.end_time = end_time + self.percent_complete = percent_complete + self.properties = properties + self.error = error + + +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -126,26 +246,22 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -170,49 +286,43 @@ class TrackedResource(Resource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class AttachedDataNetwork(TrackedResource): - """Attached data network resource. +class AttachedDataNetwork(TrackedResource): # pylint: disable=too-many-instance-attributes + """Attached data network resource. Must be created in the same location as its parent packet core data plane. Variables are only populated by the server, and will be ignored when sending a request. @@ -229,17 +339,20 @@ class AttachedDataNetwork(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the attached data network resource. Known - values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and + "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar user_plane_data_interface: Required. The user plane interface on the data network. For 5G - networks, this is the N6 interface. For 4G networks, this is the SGi interface. + :ivar user_plane_data_interface: The user plane interface on the data network. For 5G networks, + this is the N6 interface. For 4G networks, this is the SGi interface. Required. :vartype user_plane_data_interface: ~azure.mgmt.mobilenetwork.models.InterfaceProperties :ivar dns_addresses: The DNS servers to signal to UEs to use for this attached data network. + This configuration is mandatory - if you don't want DNS servers, you must provide an empty + array. Required. :vartype dns_addresses: list[str] :ivar napt_configuration: The network address and port translation (NAPT) configuration. If this is not specified, the attached data network will use a default NAPT configuration with @@ -264,31 +377,34 @@ class AttachedDataNetwork(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'user_plane_data_interface': {'required': True}, - 'dns_addresses': {'unique': True}, - 'user_equipment_address_pool_prefix': {'min_items': 1, 'unique': True}, - 'user_equipment_static_address_pool_prefix': {'min_items': 1, 'unique': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "user_plane_data_interface": {"required": True}, + "dns_addresses": {"required": True, "unique": True}, + "user_equipment_address_pool_prefix": {"min_items": 1, "unique": True}, + "user_equipment_static_address_pool_prefix": {"min_items": 1, "unique": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'user_plane_data_interface': {'key': 'properties.userPlaneDataInterface', 'type': 'InterfaceProperties'}, - 'dns_addresses': {'key': 'properties.dnsAddresses', 'type': '[str]'}, - 'napt_configuration': {'key': 'properties.naptConfiguration', 'type': 'NaptConfiguration'}, - 'user_equipment_address_pool_prefix': {'key': 'properties.userEquipmentAddressPoolPrefix', 'type': '[str]'}, - 'user_equipment_static_address_pool_prefix': {'key': 'properties.userEquipmentStaticAddressPoolPrefix', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "user_plane_data_interface": {"key": "properties.userPlaneDataInterface", "type": "InterfaceProperties"}, + "dns_addresses": {"key": "properties.dnsAddresses", "type": "[str]"}, + "napt_configuration": {"key": "properties.naptConfiguration", "type": "NaptConfiguration"}, + "user_equipment_address_pool_prefix": {"key": "properties.userEquipmentAddressPoolPrefix", "type": "[str]"}, + "user_equipment_static_address_pool_prefix": { + "key": "properties.userEquipmentStaticAddressPoolPrefix", + "type": "[str]", + }, } def __init__( @@ -296,22 +412,24 @@ def __init__( *, location: str, user_plane_data_interface: "_models.InterfaceProperties", + dns_addresses: List[str], tags: Optional[Dict[str, str]] = None, - dns_addresses: Optional[List[str]] = None, napt_configuration: Optional["_models.NaptConfiguration"] = None, user_equipment_address_pool_prefix: Optional[List[str]] = None, user_equipment_static_address_pool_prefix: Optional[List[str]] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword user_plane_data_interface: Required. The user plane interface on the data network. For - 5G networks, this is the N6 interface. For 4G networks, this is the SGi interface. + :keyword user_plane_data_interface: The user plane interface on the data network. For 5G + networks, this is the N6 interface. For 4G networks, this is the SGi interface. Required. :paramtype user_plane_data_interface: ~azure.mgmt.mobilenetwork.models.InterfaceProperties :keyword dns_addresses: The DNS servers to signal to UEs to use for this attached data network. + This configuration is mandatory - if you don't want DNS servers, you must provide an empty + array. Required. :paramtype dns_addresses: list[str] :keyword napt_configuration: The network address and port translation (NAPT) configuration. If this is not specified, the attached data network will use a default NAPT configuration with @@ -334,7 +452,7 @@ def __init__( be defined. If both are defined, they must be of the same size. :paramtype user_equipment_static_address_pool_prefix: list[str] """ - super(AttachedDataNetwork, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None self.user_plane_data_interface = user_plane_data_interface self.dns_addresses = dns_addresses @@ -343,7 +461,7 @@ def __init__( self.user_equipment_static_address_pool_prefix = user_equipment_static_address_pool_prefix -class AttachedDataNetworkListResult(msrest.serialization.Model): +class AttachedDataNetworkListResult(_serialization.Model): """Response for attached data network API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -355,155 +473,305 @@ class AttachedDataNetworkListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[AttachedDataNetwork]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AttachedDataNetwork]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.AttachedDataNetwork"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AttachedDataNetwork"]] = None, **kwargs): """ :keyword value: A list of data networks in a resource group. :paramtype value: list[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] """ - super(AttachedDataNetworkListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class AttachedDataNetworkResourceId(msrest.serialization.Model): +class AttachedDataNetworkResourceId(_serialization.Model): """Reference to an attached data network resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Attached data network resource ID. + :ivar id: Attached data network resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[pP][aA][cC][kK][eE][tT][cC][oO][rR][eE][cC][oO][nN][tT][rR][oO][lL][pP][lL][aA][nN][eE][sS]/[^/?#]+/[pP][aA][cC][kK][eE][tT][cC][oO][rR][eE][dD][aA][tT][aA][pP][lL][aA][nN][eE][sS]/[^/?#]+/[aA][tT][tT][aA][cC][hH][eE][dD][dD][aA][tT][aA][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[pP][aA][cC][kK][eE][tT][cC][oO][rR][eE][cC][oO][nN][tT][rR][oO][lL][pP][lL][aA][nN][eE][sS]/[^/?#]+/[pP][aA][cC][kK][eE][tT][cC][oO][rR][eE][dD][aA][tT][aA][pP][lL][aA][nN][eE][sS]/[^/?#]+/[aA][tT][tT][aA][cC][hH][eE][dD][dD][aA][tT][aA][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Attached data network resource ID. + :keyword id: Attached data network resource ID. Required. :paramtype id: str """ - super(AttachedDataNetworkResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class AzureStackEdgeDeviceResourceId(msrest.serialization.Model): - """Reference to an Azure Arc custom location resource. +class AzureStackEdgeDeviceResourceId(_serialization.Model): + """Reference to an Azure Stack Edge device resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Azure Stack Edge device resource ID. + :ivar id: Azure Stack Edge device resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[dD][aA][tT][aA][bB][oO][xX][eE][dD][gG][eE]/[dD][aA][tT][aA][bB][oO][xX][eE][dD][gG][eE][dD][eE][vV][iI][cC][eE][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[dD][aA][tT][aA][bB][oO][xX][eE][dD][gG][eE]/[dD][aA][tT][aA][bB][oO][xX][eE][dD][gG][eE][dD][eE][vV][iI][cC][eE][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Azure Stack Edge device resource ID. + :keyword id: Azure Stack Edge device resource ID. Required. :paramtype id: str """ - super(AzureStackEdgeDeviceResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class ConnectedClusterResourceId(msrest.serialization.Model): - """Reference to an Azure Arc custom location resource. +class AzureStackHCIClusterResourceId(_serialization.Model): + """Reference to an Azure Stack HCI cluster resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Azure Arc connected cluster resource ID. + :ivar id: Azure Stack HCI cluster resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[kK][uU][bB][eE][rR][nN][eE][tT][eE][sS]/[cC][oO][nN][nN][eE][cC][tT][eE][dD][cC][lL][uU][sS][tT][eE][rR][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[aA][zZ][uU][rR][eE][sS][tT][aA][cC][kK][hH][cC][iI]/[cC][lL][uU][sS][tT][eE][rR][sS]/[^/?#]+$", + }, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: Azure Stack HCI cluster resource ID. Required. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class CertificateProvisioning(_serialization.Model): + """Certificate provisioning state. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar state: The certificate's provisioning state. Known values are: "NotProvisioned", + "Provisioned", and "Failed". + :vartype state: str or ~azure.mgmt.mobilenetwork.models.CertificateProvisioningState + :ivar reason: Reason for certificate provisioning failure. + :vartype reason: str + """ + + _validation = { + "state": {"readonly": True}, + "reason": {"readonly": True}, + } + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.state = None + self.reason = None + + +class CommonSimPropertiesFormat(_serialization.Model): + """Common SIM properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar provisioning_state: The provisioning state of the SIM resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState + :ivar sim_state: The state of the SIM resource. Known values are: "Disabled", "Enabled", and + "Invalid". + :vartype sim_state: str or ~azure.mgmt.mobilenetwork.models.SimState + :ivar site_provisioning_state: A dictionary of sites to the provisioning state of this SIM on + that site. + :vartype site_provisioning_state: dict[str, str or + ~azure.mgmt.mobilenetwork.models.SiteProvisioningState] + :ivar international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :vartype international_mobile_subscriber_identity: str + :ivar integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the SIM. + :vartype integrated_circuit_card_identifier: str + :ivar device_type: An optional free-form text field that can be used to record the device type + this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to be + grouped and filtered based on this value. + :vartype device_type: str + :ivar sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same location + as the SIM. + :vartype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :ivar static_ip_configuration: A list of static IP addresses assigned to this SIM. Each address + is assigned at a defined network scope, made up of {attached data network, slice}. + :vartype static_ip_configuration: list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :ivar vendor_name: The name of the SIM vendor who provided this SIM, if any. + :vartype vendor_name: str + :ivar vendor_key_fingerprint: The public key fingerprint of the SIM vendor who provided this + SIM, if any. + :vartype vendor_key_fingerprint: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "sim_state": {"readonly": True}, + "site_provisioning_state": {"readonly": True}, + "international_mobile_subscriber_identity": {"required": True, "pattern": r"^[0-9]{5,15}$"}, + "integrated_circuit_card_identifier": {"pattern": r"^[0-9]{10,20}$"}, + "static_ip_configuration": {"min_items": 1, "unique": True}, + "vendor_name": {"readonly": True}, + "vendor_key_fingerprint": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "sim_state": {"key": "simState", "type": "str"}, + "site_provisioning_state": {"key": "siteProvisioningState", "type": "{str}"}, + "international_mobile_subscriber_identity": {"key": "internationalMobileSubscriberIdentity", "type": "str"}, + "integrated_circuit_card_identifier": {"key": "integratedCircuitCardIdentifier", "type": "str"}, + "device_type": {"key": "deviceType", "type": "str"}, + "sim_policy": {"key": "simPolicy", "type": "SimPolicyResourceId"}, + "static_ip_configuration": {"key": "staticIpConfiguration", "type": "[SimStaticIpProperties]"}, + "vendor_name": {"key": "vendorName", "type": "str"}, + "vendor_key_fingerprint": {"key": "vendorKeyFingerprint", "type": "str"}, } def __init__( self, *, - id: str, + international_mobile_subscriber_identity: str, + integrated_circuit_card_identifier: Optional[str] = None, + device_type: Optional[str] = None, + sim_policy: Optional["_models.SimPolicyResourceId"] = None, + static_ip_configuration: Optional[List["_models.SimStaticIpProperties"]] = None, **kwargs ): """ - :keyword id: Required. Azure Arc connected cluster resource ID. + :keyword international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :paramtype international_mobile_subscriber_identity: str + :keyword integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the + SIM. + :paramtype integrated_circuit_card_identifier: str + :keyword device_type: An optional free-form text field that can be used to record the device + type this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to + be grouped and filtered based on this value. + :paramtype device_type: str + :keyword sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same + location as the SIM. + :paramtype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :keyword static_ip_configuration: A list of static IP addresses assigned to this SIM. Each + address is assigned at a defined network scope, made up of {attached data network, slice}. + :paramtype static_ip_configuration: + list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.sim_state = None + self.site_provisioning_state = None + self.international_mobile_subscriber_identity = international_mobile_subscriber_identity + self.integrated_circuit_card_identifier = integrated_circuit_card_identifier + self.device_type = device_type + self.sim_policy = sim_policy + self.static_ip_configuration = static_ip_configuration + self.vendor_name = None + self.vendor_key_fingerprint = None + + +class ConnectedClusterResourceId(_serialization.Model): + """Reference to an Azure Arc custom location resource. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure Arc connected cluster resource ID. Required. + :vartype id: str + """ + + _validation = { + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[kK][uU][bB][eE][rR][nN][eE][tT][eE][sS]/[cC][oO][nN][nN][eE][cC][tT][eE][dD][cC][lL][uU][sS][tT][eE][rR][sS]/[^/?#]+$", + }, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: Azure Arc connected cluster resource ID. Required. :paramtype id: str """ - super(ConnectedClusterResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class CustomLocationResourceId(msrest.serialization.Model): +class CustomLocationResourceId(_serialization.Model): """Reference to an Azure Arc custom location resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Azure Arc custom location resource ID. + :ivar id: Azure Arc custom location resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[eE][xX][tT][eE][nN][dD][eE][dD][lL][oO][cC][aA][tT][iI][oO][nN]/[cC][uU][sS][tT][oO][mM][lL][oO][cC][aA][tT][iI][oO][nN][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[eE][xX][tT][eE][nN][dD][eE][dD][lL][oO][cC][aA][tT][iI][oO][nN]/[cC][uU][sS][tT][oO][mM][lL][oO][cC][aA][tT][iI][oO][nN][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Azure Arc custom location resource ID. + :keyword id: Azure Arc custom location resource ID. Required. :paramtype id: str """ - super(CustomLocationResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id class DataNetwork(TrackedResource): - """Data network resource. + """Data network resource. Must be created in the same location as its parent mobile network. Variables are only populated by the server, and will be ignored when sending a request. @@ -520,68 +788,64 @@ class DataNetwork(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the data network resource. Known values - are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState :ivar description: An optional description for this data network. :vartype description: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, } def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - **kwargs + self, *, location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword description: An optional description for this data network. :paramtype description: str """ - super(DataNetwork, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None self.description = description -class DataNetworkConfiguration(msrest.serialization.Model): +class DataNetworkConfiguration(_serialization.Model): """Settings controlling data network use. All required parameters must be populated in order to send to Azure. - :ivar data_network: Required. A reference to the data network that these settings apply to. + :ivar data_network: A reference to the data network that these settings apply to. The data + network must be in the same location as the SIM policy. Required. :vartype data_network: ~azure.mgmt.mobilenetwork.models.DataNetworkResourceId - :ivar session_ambr: Required. Aggregate maximum bit rate across all non-GBR QoS flows of a - given PDU session. See 3GPP TS23.501 section 5.7.2.6 for a full description of the - Session-AMBR. + :ivar session_ambr: Aggregate maximum bit rate across all non-GBR QoS flows of a given PDU + session. See 3GPP TS23.501 section 5.7.2.6 for a full description of the Session-AMBR. + Required. :vartype session_ambr: ~azure.mgmt.mobilenetwork.models.Ambr :ivar five_qi: Default QoS Flow 5G QoS Indicator value. The 5QI identifies a specific QoS forwarding treatment to be provided to a flow. This must not be a standardized 5QI value @@ -599,45 +863,53 @@ class DataNetworkConfiguration(msrest.serialization.Model): :ivar preemption_capability: Default QoS Flow preemption capability. The preemption capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known values are: - "NotPreempt", "MayPreempt". + "NotPreempt" and "MayPreempt". :vartype preemption_capability: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability :ivar preemption_vulnerability: Default QoS Flow preemption vulnerability. The preemption vulnerability of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. - Known values are: "NotPreemptable", "Preemptable". + Known values are: "NotPreemptable" and "Preemptable". :vartype preemption_vulnerability: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability :ivar default_session_type: The default PDU session type, which is used if the UE does not - request a specific session type. Known values are: "IPv4", "IPv6". + request a specific session type. Known values are: "IPv4" and "IPv6". :vartype default_session_type: str or ~azure.mgmt.mobilenetwork.models.PduSessionType :ivar additional_allowed_session_types: Allowed session types in addition to the default session type. Must not duplicate the default session type. :vartype additional_allowed_session_types: list[str or ~azure.mgmt.mobilenetwork.models.PduSessionType] - :ivar allowed_services: Required. List of services that can be used as part of this SIM policy. - The list must not contain duplicate items and must contain at least one item. + :ivar allowed_services: List of services that can be used as part of this SIM policy. The list + must not contain duplicate items and must contain at least one item. The services must be in + the same location as the SIM policy. Required. :vartype allowed_services: list[~azure.mgmt.mobilenetwork.models.ServiceResourceId] + :ivar maximum_number_of_buffered_packets: The maximum number of downlink packets to buffer at + the user plane for High Latency Communication - Extended Buffering. See 3GPP TS29.272 v15.10.0 + section 7.3.188 for a full description. This maximum is not guaranteed because there is a + internal limit on buffered packets across all PDU sessions. + :vartype maximum_number_of_buffered_packets: int """ _validation = { - 'data_network': {'required': True}, - 'session_ambr': {'required': True}, - 'five_qi': {'maximum': 127, 'minimum': 1}, - 'allocation_and_retention_priority_level': {'maximum': 15, 'minimum': 1}, - 'additional_allowed_session_types': {'max_items': 1, 'min_items': 0}, - 'allowed_services': {'required': True, 'min_items': 1, 'unique': True}, + "data_network": {"required": True}, + "session_ambr": {"required": True}, + "five_qi": {"maximum": 255, "minimum": 0}, + "allocation_and_retention_priority_level": {"maximum": 15, "minimum": 1}, + "additional_allowed_session_types": {"max_items": 1, "min_items": 0}, + "allowed_services": {"required": True, "min_items": 1, "unique": True}, + "maximum_number_of_buffered_packets": {"minimum": 0}, } _attribute_map = { - 'data_network': {'key': 'dataNetwork', 'type': 'DataNetworkResourceId'}, - 'session_ambr': {'key': 'sessionAmbr', 'type': 'Ambr'}, - 'five_qi': {'key': '5qi', 'type': 'int'}, - 'allocation_and_retention_priority_level': {'key': 'allocationAndRetentionPriorityLevel', 'type': 'int'}, - 'preemption_capability': {'key': 'preemptionCapability', 'type': 'str'}, - 'preemption_vulnerability': {'key': 'preemptionVulnerability', 'type': 'str'}, - 'default_session_type': {'key': 'defaultSessionType', 'type': 'str'}, - 'additional_allowed_session_types': {'key': 'additionalAllowedSessionTypes', 'type': '[str]'}, - 'allowed_services': {'key': 'allowedServices', 'type': '[ServiceResourceId]'}, + "data_network": {"key": "dataNetwork", "type": "DataNetworkResourceId"}, + "session_ambr": {"key": "sessionAmbr", "type": "Ambr"}, + "five_qi": {"key": "5qi", "type": "int"}, + "allocation_and_retention_priority_level": {"key": "allocationAndRetentionPriorityLevel", "type": "int"}, + "preemption_capability": {"key": "preemptionCapability", "type": "str"}, + "preemption_vulnerability": {"key": "preemptionVulnerability", "type": "str"}, + "default_session_type": {"key": "defaultSessionType", "type": "str"}, + "additional_allowed_session_types": {"key": "additionalAllowedSessionTypes", "type": "[str]"}, + "allowed_services": {"key": "allowedServices", "type": "[ServiceResourceId]"}, + "maximum_number_of_buffered_packets": {"key": "maximumNumberOfBufferedPackets", "type": "int"}, } def __init__( @@ -652,14 +924,16 @@ def __init__( preemption_vulnerability: Optional[Union[str, "_models.PreemptionVulnerability"]] = None, default_session_type: Optional[Union[str, "_models.PduSessionType"]] = None, additional_allowed_session_types: Optional[List[Union[str, "_models.PduSessionType"]]] = None, + maximum_number_of_buffered_packets: int = 10, **kwargs ): """ - :keyword data_network: Required. A reference to the data network that these settings apply to. + :keyword data_network: A reference to the data network that these settings apply to. The data + network must be in the same location as the SIM policy. Required. :paramtype data_network: ~azure.mgmt.mobilenetwork.models.DataNetworkResourceId - :keyword session_ambr: Required. Aggregate maximum bit rate across all non-GBR QoS flows of a - given PDU session. See 3GPP TS23.501 section 5.7.2.6 for a full description of the - Session-AMBR. + :keyword session_ambr: Aggregate maximum bit rate across all non-GBR QoS flows of a given PDU + session. See 3GPP TS23.501 section 5.7.2.6 for a full description of the Session-AMBR. + Required. :paramtype session_ambr: ~azure.mgmt.mobilenetwork.models.Ambr :keyword five_qi: Default QoS Flow 5G QoS Indicator value. The 5QI identifies a specific QoS forwarding treatment to be provided to a flow. This must not be a standardized 5QI value @@ -677,26 +951,32 @@ def __init__( :keyword preemption_capability: Default QoS Flow preemption capability. The preemption capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known - values are: "NotPreempt", "MayPreempt". + values are: "NotPreempt" and "MayPreempt". :paramtype preemption_capability: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability :keyword preemption_vulnerability: Default QoS Flow preemption vulnerability. The preemption vulnerability of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. - Known values are: "NotPreemptable", "Preemptable". + Known values are: "NotPreemptable" and "Preemptable". :paramtype preemption_vulnerability: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability :keyword default_session_type: The default PDU session type, which is used if the UE does not - request a specific session type. Known values are: "IPv4", "IPv6". + request a specific session type. Known values are: "IPv4" and "IPv6". :paramtype default_session_type: str or ~azure.mgmt.mobilenetwork.models.PduSessionType :keyword additional_allowed_session_types: Allowed session types in addition to the default session type. Must not duplicate the default session type. :paramtype additional_allowed_session_types: list[str or ~azure.mgmt.mobilenetwork.models.PduSessionType] - :keyword allowed_services: Required. List of services that can be used as part of this SIM - policy. The list must not contain duplicate items and must contain at least one item. + :keyword allowed_services: List of services that can be used as part of this SIM policy. The + list must not contain duplicate items and must contain at least one item. The services must be + in the same location as the SIM policy. Required. :paramtype allowed_services: list[~azure.mgmt.mobilenetwork.models.ServiceResourceId] + :keyword maximum_number_of_buffered_packets: The maximum number of downlink packets to buffer + at the user plane for High Latency Communication - Extended Buffering. See 3GPP TS29.272 + v15.10.0 section 7.3.188 for a full description. This maximum is not guaranteed because there + is a internal limit on buffered packets across all PDU sessions. + :paramtype maximum_number_of_buffered_packets: int """ - super(DataNetworkConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.data_network = data_network self.session_ambr = session_ambr self.five_qi = five_qi @@ -706,9 +986,10 @@ def __init__( self.default_session_type = default_session_type self.additional_allowed_session_types = additional_allowed_session_types self.allowed_services = allowed_services + self.maximum_number_of_buffered_packets = maximum_number_of_buffered_packets -class DataNetworkListResult(msrest.serialization.Model): +class DataNetworkListResult(_serialization.Model): """Response for data network API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -720,140 +1001,314 @@ class DataNetworkListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataNetwork]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataNetwork]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.DataNetwork"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DataNetwork"]] = None, **kwargs): """ :keyword value: A list of data networks. :paramtype value: list[~azure.mgmt.mobilenetwork.models.DataNetwork] """ - super(DataNetworkListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DataNetworkResourceId(msrest.serialization.Model): +class DataNetworkResourceId(_serialization.Model): """Reference to a data network resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Data network resource ID. + :ivar id: Data network resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[dD][aA][tT][aA][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[dD][aA][tT][aA][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Data network resource ID. + :keyword id: Data network resource ID. Required. :paramtype id: str """ - super(DataNetworkResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. +class EncryptedSimPropertiesFormat(CommonSimPropertiesFormat): # pylint: disable=too-many-instance-attributes + """Encrypted SIM properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any + All required parameters must be populated in order to send to Azure. + + :ivar provisioning_state: The provisioning state of the SIM resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState + :ivar sim_state: The state of the SIM resource. Known values are: "Disabled", "Enabled", and + "Invalid". + :vartype sim_state: str or ~azure.mgmt.mobilenetwork.models.SimState + :ivar site_provisioning_state: A dictionary of sites to the provisioning state of this SIM on + that site. + :vartype site_provisioning_state: dict[str, str or + ~azure.mgmt.mobilenetwork.models.SiteProvisioningState] + :ivar international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :vartype international_mobile_subscriber_identity: str + :ivar integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the SIM. + :vartype integrated_circuit_card_identifier: str + :ivar device_type: An optional free-form text field that can be used to record the device type + this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to be + grouped and filtered based on this value. + :vartype device_type: str + :ivar sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same location + as the SIM. + :vartype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :ivar static_ip_configuration: A list of static IP addresses assigned to this SIM. Each address + is assigned at a defined network scope, made up of {attached data network, slice}. + :vartype static_ip_configuration: list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :ivar vendor_name: The name of the SIM vendor who provided this SIM, if any. + :vartype vendor_name: str + :ivar vendor_key_fingerprint: The public key fingerprint of the SIM vendor who provided this + SIM, if any. + :vartype vendor_key_fingerprint: str + :ivar encrypted_credentials: The encrypted SIM credentials. + :vartype encrypted_credentials: str """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "sim_state": {"readonly": True}, + "site_provisioning_state": {"readonly": True}, + "international_mobile_subscriber_identity": {"required": True, "pattern": r"^[0-9]{5,15}$"}, + "integrated_circuit_card_identifier": {"pattern": r"^[0-9]{10,20}$"}, + "static_ip_configuration": {"min_items": 1, "unique": True}, + "vendor_name": {"readonly": True}, + "vendor_key_fingerprint": {"readonly": True}, + "encrypted_credentials": {"pattern": r"^[0-9a-fA-F]+$"}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "sim_state": {"key": "simState", "type": "str"}, + "site_provisioning_state": {"key": "siteProvisioningState", "type": "{str}"}, + "international_mobile_subscriber_identity": {"key": "internationalMobileSubscriberIdentity", "type": "str"}, + "integrated_circuit_card_identifier": {"key": "integratedCircuitCardIdentifier", "type": "str"}, + "device_type": {"key": "deviceType", "type": "str"}, + "sim_policy": {"key": "simPolicy", "type": "SimPolicyResourceId"}, + "static_ip_configuration": {"key": "staticIpConfiguration", "type": "[SimStaticIpProperties]"}, + "vendor_name": {"key": "vendorName", "type": "str"}, + "vendor_key_fingerprint": {"key": "vendorKeyFingerprint", "type": "str"}, + "encrypted_credentials": {"key": "encryptedCredentials", "type": "str"}, } def __init__( self, + *, + international_mobile_subscriber_identity: str, + integrated_circuit_card_identifier: Optional[str] = None, + device_type: Optional[str] = None, + sim_policy: Optional["_models.SimPolicyResourceId"] = None, + static_ip_configuration: Optional[List["_models.SimStaticIpProperties"]] = None, + encrypted_credentials: Optional[str] = None, **kwargs ): """ + :keyword international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :paramtype international_mobile_subscriber_identity: str + :keyword integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the + SIM. + :paramtype integrated_circuit_card_identifier: str + :keyword device_type: An optional free-form text field that can be used to record the device + type this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to + be grouped and filtered based on this value. + :paramtype device_type: str + :keyword sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same + location as the SIM. + :paramtype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :keyword static_ip_configuration: A list of static IP addresses assigned to this SIM. Each + address is assigned at a defined network scope, made up of {attached data network, slice}. + :paramtype static_ip_configuration: + list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :keyword encrypted_credentials: The encrypted SIM credentials. + :paramtype encrypted_credentials: str """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None + super().__init__( + international_mobile_subscriber_identity=international_mobile_subscriber_identity, + integrated_circuit_card_identifier=integrated_circuit_card_identifier, + device_type=device_type, + sim_policy=sim_policy, + static_ip_configuration=static_ip_configuration, + **kwargs + ) + self.encrypted_credentials = encrypted_credentials -class ErrorDetail(msrest.serialization.Model): - """The error detail. +class EncryptedSimUploadList(_serialization.Model): + """The SIMs to upload. The SIM credentials must be encrypted. - 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. - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.mobilenetwork.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.mobilenetwork.models.ErrorAdditionalInfo] + :ivar version: The upload file format version. Required. + :vartype version: int + :ivar azure_key_identifier: An identifier for the Azure SIM onboarding public key used for + encrypted upload. Required. + :vartype azure_key_identifier: int + :ivar vendor_key_fingerprint: The fingerprint of the SIM vendor public key. The private + counterpart is used for signing the encrypted transport key. Required. + :vartype vendor_key_fingerprint: str + :ivar encrypted_transport_key: The transport key used for encrypting SIM credentials, encrypted + using the SIM onboarding public key. Required. + :vartype encrypted_transport_key: str + :ivar signed_transport_key: The encrypted transport key, signed using the SIM vendor private + key. Required. + :vartype signed_transport_key: str + :ivar sims: A list of SIMs to upload, with encrypted properties. Required. + :vartype sims: list[~azure.mgmt.mobilenetwork.models.SimNameAndEncryptedProperties] """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "version": {"required": True, "minimum": 1}, + "azure_key_identifier": {"required": True, "minimum": 1}, + "vendor_key_fingerprint": {"required": True, "pattern": r"^[0-9a-fA-F]+$"}, + "encrypted_transport_key": {"required": True, "pattern": r"^[0-9a-fA-F]+$"}, + "signed_transport_key": {"required": True, "pattern": r"^[0-9a-fA-F]+$"}, + "sims": {"required": True, "min_items": 1}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "version": {"key": "version", "type": "int"}, + "azure_key_identifier": {"key": "azureKeyIdentifier", "type": "int"}, + "vendor_key_fingerprint": {"key": "vendorKeyFingerprint", "type": "str"}, + "encrypted_transport_key": {"key": "encryptedTransportKey", "type": "str"}, + "signed_transport_key": {"key": "signedTransportKey", "type": "str"}, + "sims": {"key": "sims", "type": "[SimNameAndEncryptedProperties]"}, } def __init__( self, + *, + version: int, + azure_key_identifier: int, + vendor_key_fingerprint: str, + encrypted_transport_key: str, + signed_transport_key: str, + sims: List["_models.SimNameAndEncryptedProperties"], **kwargs ): """ - """ - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None + :keyword version: The upload file format version. Required. + :paramtype version: int + :keyword azure_key_identifier: An identifier for the Azure SIM onboarding public key used for + encrypted upload. Required. + :paramtype azure_key_identifier: int + :keyword vendor_key_fingerprint: The fingerprint of the SIM vendor public key. The private + counterpart is used for signing the encrypted transport key. Required. + :paramtype vendor_key_fingerprint: str + :keyword encrypted_transport_key: The transport key used for encrypting SIM credentials, + encrypted using the SIM onboarding public key. Required. + :paramtype encrypted_transport_key: str + :keyword signed_transport_key: The encrypted transport key, signed using the SIM vendor private + key. Required. + :paramtype signed_transport_key: str + :keyword sims: A list of SIMs to upload, with encrypted properties. Required. + :paramtype sims: list[~azure.mgmt.mobilenetwork.models.SimNameAndEncryptedProperties] + """ + super().__init__(**kwargs) + self.version = version + self.azure_key_identifier = azure_key_identifier + self.vendor_key_fingerprint = vendor_key_fingerprint + self.encrypted_transport_key = encrypted_transport_key + self.signed_transport_key = signed_transport_key + self.sims = sims + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.mobilenetwork.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.mobilenetwork.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None self.details = None self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -861,24 +1316,88 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.mobilenetwork.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class HttpsServerCertificate(_serialization.Model): + """HTTPS server certificate configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar certificate_url: The certificate URL, unversioned. For example: + https://contosovault.vault.azure.net/certificates/ingress. Required. + :vartype certificate_url: str + :ivar provisioning: The provisioning state of the certificate. + :vartype provisioning: ~azure.mgmt.mobilenetwork.models.CertificateProvisioning + """ + + _validation = { + "certificate_url": {"required": True}, + "provisioning": {"readonly": True}, + } + + _attribute_map = { + "certificate_url": {"key": "certificateUrl", "type": "str"}, + "provisioning": {"key": "provisioning", "type": "CertificateProvisioning"}, + } + + def __init__(self, *, certificate_url: str, **kwargs): + """ + :keyword certificate_url: The certificate URL, unversioned. For example: + https://contosovault.vault.azure.net/certificates/ingress. Required. + :paramtype certificate_url: str + """ + super().__init__(**kwargs) + self.certificate_url = certificate_url + self.provisioning = None + + +class Installation(_serialization.Model): + """The installation state of the packet core. + + :ivar state: Installation state. Known values are: "Uninstalled", "Installing", "Installed", + "Updating", "Upgrading", "Uninstalling", "Reinstalling", "RollingBack", and "Failed". + :vartype state: str or ~azure.mgmt.mobilenetwork.models.InstallationState + :ivar operation: A reference to an in-progress installation operation. + :vartype operation: ~azure.mgmt.mobilenetwork.models.AsyncOperationId + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "operation": {"key": "operation", "type": "AsyncOperationId"}, } def __init__( self, *, - error: Optional["_models.ErrorDetail"] = None, + state: Optional[Union[str, "_models.InstallationState"]] = None, + operation: Optional["_models.AsyncOperationId"] = None, **kwargs ): """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.mobilenetwork.models.ErrorDetail + :keyword state: Installation state. Known values are: "Uninstalled", "Installing", "Installed", + "Updating", "Upgrading", "Uninstalling", "Reinstalling", "RollingBack", and "Failed". + :paramtype state: str or ~azure.mgmt.mobilenetwork.models.InstallationState + :keyword operation: A reference to an in-progress installation operation. + :paramtype operation: ~azure.mgmt.mobilenetwork.models.AsyncOperationId """ - super(ErrorResponse, self).__init__(**kwargs) - self.error = error + super().__init__(**kwargs) + self.state = state + self.operation = operation -class InterfaceProperties(msrest.serialization.Model): +class InterfaceProperties(_serialization.Model): """Interface properties. :ivar name: The logical name for this interface. This should match one of the interfaces @@ -893,16 +1412,22 @@ class InterfaceProperties(msrest.serialization.Model): """ _validation = { - 'ipv4_address': {'pattern': r'^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$'}, - 'ipv4_subnet': {'pattern': r'^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$'}, - 'ipv4_gateway': {'pattern': r'^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$'}, + "ipv4_address": { + "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$" + }, + "ipv4_subnet": { + "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$" + }, + "ipv4_gateway": { + "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$" + }, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, - 'ipv4_subnet': {'key': 'ipv4Subnet', 'type': 'str'}, - 'ipv4_gateway': {'key': 'ipv4Gateway', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "ipv4_address": {"key": "ipv4Address", "type": "str"}, + "ipv4_subnet": {"key": "ipv4Subnet", "type": "str"}, + "ipv4_gateway": {"key": "ipv4Gateway", "type": "str"}, } def __init__( @@ -925,41 +1450,14 @@ def __init__( :keyword ipv4_gateway: The default IPv4 gateway (router). :paramtype ipv4_gateway: str """ - super(InterfaceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.ipv4_address = ipv4_address self.ipv4_subnet = ipv4_subnet self.ipv4_gateway = ipv4_gateway -class KeyVaultCertificate(msrest.serialization.Model): - """An Azure key vault certificate. - - :ivar certificate_url: The certificate URL, unversioned. For example: - https://contosovault.vault.azure.net/certificates/ingress. - :vartype certificate_url: str - """ - - _attribute_map = { - 'certificate_url': {'key': 'certificateUrl', 'type': 'str'}, - } - - def __init__( - self, - *, - certificate_url: Optional[str] = None, - **kwargs - ): - """ - :keyword certificate_url: The certificate URL, unversioned. For example: - https://contosovault.vault.azure.net/certificates/ingress. - :paramtype certificate_url: str - """ - super(KeyVaultCertificate, self).__init__(**kwargs) - self.certificate_url = certificate_url - - -class KeyVaultKey(msrest.serialization.Model): +class KeyVaultKey(_serialization.Model): """An Azure key vault key. :ivar key_url: The key URL, unversioned. For example: @@ -968,52 +1466,62 @@ class KeyVaultKey(msrest.serialization.Model): """ _attribute_map = { - 'key_url': {'key': 'keyUrl', 'type': 'str'}, + "key_url": {"key": "keyUrl", "type": "str"}, } - def __init__( - self, - *, - key_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_url: Optional[str] = None, **kwargs): """ :keyword key_url: The key URL, unversioned. For example: https://contosovault.vault.azure.net/keys/azureKey. :paramtype key_url: str """ - super(KeyVaultKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_url = key_url -class LocalDiagnosticsAccessConfiguration(msrest.serialization.Model): +class LocalDiagnosticsAccessConfiguration(_serialization.Model): """The kubernetes ingress configuration to control access to packet core diagnostics over local APIs. + All required parameters must be populated in order to send to Azure. + + :ivar authentication_type: How to authenticate users who access local diagnostics APIs. + Required. Known values are: "AAD" and "Password". + :vartype authentication_type: str or ~azure.mgmt.mobilenetwork.models.AuthenticationType :ivar https_server_certificate: The HTTPS server TLS certificate used to secure local access to diagnostics. - :vartype https_server_certificate: ~azure.mgmt.mobilenetwork.models.KeyVaultCertificate + :vartype https_server_certificate: ~azure.mgmt.mobilenetwork.models.HttpsServerCertificate """ + _validation = { + "authentication_type": {"required": True}, + } + _attribute_map = { - 'https_server_certificate': {'key': 'httpsServerCertificate', 'type': 'KeyVaultCertificate'}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "https_server_certificate": {"key": "httpsServerCertificate", "type": "HttpsServerCertificate"}, } def __init__( self, *, - https_server_certificate: Optional["_models.KeyVaultCertificate"] = None, + authentication_type: Union[str, "_models.AuthenticationType"], + https_server_certificate: Optional["_models.HttpsServerCertificate"] = None, **kwargs ): """ + :keyword authentication_type: How to authenticate users who access local diagnostics APIs. + Required. Known values are: "AAD" and "Password". + :paramtype authentication_type: str or ~azure.mgmt.mobilenetwork.models.AuthenticationType :keyword https_server_certificate: The HTTPS server TLS certificate used to secure local access to diagnostics. - :paramtype https_server_certificate: ~azure.mgmt.mobilenetwork.models.KeyVaultCertificate + :paramtype https_server_certificate: ~azure.mgmt.mobilenetwork.models.HttpsServerCertificate """ - super(LocalDiagnosticsAccessConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) + self.authentication_type = authentication_type self.https_server_certificate = https_server_certificate -class ManagedServiceIdentity(msrest.serialization.Model): +class ManagedServiceIdentity(_serialization.Model): """Managed service identity (system assigned and/or user assigned identities). Variables are only populated by the server, and will be ignored when sending a request. @@ -1026,8 +1534,8 @@ class ManagedServiceIdentity(msrest.serialization.Model): :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :ivar type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.mobilenetwork.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the @@ -1039,16 +1547,16 @@ class ManagedServiceIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -1059,8 +1567,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", + :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned + types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.mobilenetwork.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the @@ -1070,7 +1578,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.mobilenetwork.models.UserAssignedIdentity] """ - super(ManagedServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -1095,43 +1603,46 @@ class MobileNetwork(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the mobile network resource. Known values - are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar public_land_mobile_network_identifier: Required. The unique public land mobile network - identifier for the network. This is made up of the mobile country code and mobile network code, - as defined in https://www.itu.int/rec/T-REC-E.212. The values 001-01 and 001-001 can be used - for testing and the values 999-99 and 999-999 can be used on internal private networks. + :ivar public_land_mobile_network_identifier: The unique public land mobile network identifier + for the network. This is made up of the mobile country code and mobile network code, as defined + in https://www.itu.int/rec/T-REC-E.212. The values 001-01 and 001-001 can be used for testing + and the values 999-99 and 999-999 can be used on internal private networks. Required. :vartype public_land_mobile_network_identifier: ~azure.mgmt.mobilenetwork.models.PlmnId :ivar service_key: The mobile network resource identifier. :vartype service_key: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'public_land_mobile_network_identifier': {'required': True}, - 'service_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "public_land_mobile_network_identifier": {"required": True}, + "service_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'public_land_mobile_network_identifier': {'key': 'properties.publicLandMobileNetworkIdentifier', 'type': 'PlmnId'}, - 'service_key': {'key': 'properties.serviceKey', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "public_land_mobile_network_identifier": { + "key": "properties.publicLandMobileNetworkIdentifier", + "type": "PlmnId", + }, + "service_key": {"key": "properties.serviceKey", "type": "str"}, } def __init__( @@ -1143,23 +1654,24 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword public_land_mobile_network_identifier: Required. The unique public land mobile network + :keyword public_land_mobile_network_identifier: The unique public land mobile network identifier for the network. This is made up of the mobile country code and mobile network code, as defined in https://www.itu.int/rec/T-REC-E.212. The values 001-01 and 001-001 can be used for testing and the values 999-99 and 999-999 can be used on internal private networks. + Required. :paramtype public_land_mobile_network_identifier: ~azure.mgmt.mobilenetwork.models.PlmnId """ - super(MobileNetwork, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None self.public_land_mobile_network_identifier = public_land_mobile_network_identifier self.service_key = None -class MobileNetworkListResult(msrest.serialization.Model): +class MobileNetworkListResult(_serialization.Model): """Response for mobile networks API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -1171,65 +1683,58 @@ class MobileNetworkListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MobileNetwork]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MobileNetwork]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MobileNetwork"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MobileNetwork"]] = None, **kwargs): """ :keyword value: A list of mobile networks in a resource group. :paramtype value: list[~azure.mgmt.mobilenetwork.models.MobileNetwork] """ - super(MobileNetworkListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MobileNetworkResourceId(msrest.serialization.Model): +class MobileNetworkResourceId(_serialization.Model): """Reference to a mobile network resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Mobile network resource ID. + :ivar id: Mobile network resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Mobile network resource ID. + :keyword id: Mobile network resource ID. Required. :paramtype id: str """ - super(MobileNetworkResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class NaptConfiguration(msrest.serialization.Model): +class NaptConfiguration(_serialization.Model): """The network address and port translation settings to use for the attached data network. :ivar enabled: Whether NAPT is enabled for connections to this attached data network. Known - values are: "Enabled", "Disabled". Default value: "Enabled". + values are: "Enabled" and "Disabled". :vartype enabled: str or ~azure.mgmt.mobilenetwork.models.NaptEnabled :ivar port_range: Range of port numbers to use as translated ports on each translated address. If not specified and NAPT is enabled, this range defaults to 1,024 - 49,999. @@ -1237,8 +1742,8 @@ class NaptConfiguration(msrest.serialization.Model): IANA. Ports 50,000 and above are reserved for non-NAPT use.). :vartype port_range: ~azure.mgmt.mobilenetwork.models.PortRange :ivar port_reuse_hold_time: The minimum time (in seconds) that will pass before a port that was - used by a closed pinhole can be recycled for use by another pinhole. All hold times must be - minimum 1 second. + used by a closed pinhole can be recycled for use by another pinhole. All hold times must be at + least 1 second. :vartype port_reuse_hold_time: ~azure.mgmt.mobilenetwork.models.PortReuseHoldTimes :ivar pinhole_limits: Maximum number of UDP and TCP pinholes that can be open simultaneously on the core interface. For 5G networks, this is the N6 interface. For 4G networks, this is the SGi @@ -1250,30 +1755,30 @@ class NaptConfiguration(msrest.serialization.Model): """ _validation = { - 'pinhole_limits': {'maximum': 65536, 'minimum': 1}, + "pinhole_limits": {"maximum": 65536, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'port_range': {'key': 'portRange', 'type': 'PortRange'}, - 'port_reuse_hold_time': {'key': 'portReuseHoldTime', 'type': 'PortReuseHoldTimes'}, - 'pinhole_limits': {'key': 'pinholeLimits', 'type': 'int'}, - 'pinhole_timeouts': {'key': 'pinholeTimeouts', 'type': 'PinholeTimeouts'}, + "enabled": {"key": "enabled", "type": "str"}, + "port_range": {"key": "portRange", "type": "PortRange"}, + "port_reuse_hold_time": {"key": "portReuseHoldTime", "type": "PortReuseHoldTimes"}, + "pinhole_limits": {"key": "pinholeLimits", "type": "int"}, + "pinhole_timeouts": {"key": "pinholeTimeouts", "type": "PinholeTimeouts"}, } def __init__( self, *, - enabled: Optional[Union[str, "_models.NaptEnabled"]] = "Enabled", + enabled: Union[str, "_models.NaptEnabled"] = "Enabled", port_range: Optional["_models.PortRange"] = None, port_reuse_hold_time: Optional["_models.PortReuseHoldTimes"] = None, - pinhole_limits: Optional[int] = 65536, + pinhole_limits: int = 65536, pinhole_timeouts: Optional["_models.PinholeTimeouts"] = None, **kwargs ): """ :keyword enabled: Whether NAPT is enabled for connections to this attached data network. Known - values are: "Enabled", "Disabled". Default value: "Enabled". + values are: "Enabled" and "Disabled". :paramtype enabled: str or ~azure.mgmt.mobilenetwork.models.NaptEnabled :keyword port_range: Range of port numbers to use as translated ports on each translated address. @@ -1283,7 +1788,7 @@ def __init__( :paramtype port_range: ~azure.mgmt.mobilenetwork.models.PortRange :keyword port_reuse_hold_time: The minimum time (in seconds) that will pass before a port that was used by a closed pinhole can be recycled for use by another pinhole. All hold times must be - minimum 1 second. + at least 1 second. :paramtype port_reuse_hold_time: ~azure.mgmt.mobilenetwork.models.PortReuseHoldTimes :keyword pinhole_limits: Maximum number of UDP and TCP pinholes that can be open simultaneously on the core interface. For 5G networks, this is the N6 interface. For 4G networks, this is the @@ -1293,7 +1798,7 @@ def __init__( be at least 1 second. :paramtype pinhole_timeouts: ~azure.mgmt.mobilenetwork.models.PinholeTimeouts """ - super(NaptConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.port_range = port_range self.port_reuse_hold_time = port_reuse_hold_time @@ -1301,7 +1806,7 @@ def __init__( self.pinhole_timeouts = pinhole_timeouts -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Object that describes a single Microsoft.MobileNetwork operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1315,33 +1820,28 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, + "name": {"readonly": True}, + "display": {"readonly": True}, } _attribute_map = { - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - is_data_action: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_data_action: Optional[bool] = None, **kwargs): """ :keyword is_data_action: Indicates whether the operation applies to data-plane. :paramtype is_data_action: bool """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_data_action = is_data_action self.name = None self.display = None -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.MobileNetwork. @@ -1356,10 +1856,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1382,14 +1882,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationList(msrest.serialization.Model): +class OperationList(_serialization.Model): """List of the operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -1401,27 +1901,23 @@ class OperationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PacketCoreControlPlane(TrackedResource): +class PacketCoreControlPlane(TrackedResource): # pylint: disable=too-many-instance-attributes """Packet core control plane resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1439,137 +1935,192 @@ class PacketCoreControlPlane(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar identity: The identity used to retrieve the ingress certificate from Azure key vault. :vartype identity: ~azure.mgmt.mobilenetwork.models.ManagedServiceIdentity :ivar provisioning_state: The provisioning state of the packet core control plane resource. - Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar mobile_network: Required. Mobile network in which this packet core control plane is - deployed. - :vartype mobile_network: ~azure.mgmt.mobilenetwork.models.MobileNetworkResourceId - :ivar platform: The platform where the packet core is deployed. + :ivar installation: The installation state of the packet core control plane resource. + :vartype installation: ~azure.mgmt.mobilenetwork.models.Installation + :ivar sites: Site(s) under which this packet core control plane should be deployed. The sites + must be in the same location as the packet core control plane. Required. + :vartype sites: list[~azure.mgmt.mobilenetwork.models.SiteResourceId] + :ivar platform: The platform where the packet core is deployed. Required. :vartype platform: ~azure.mgmt.mobilenetwork.models.PlatformConfiguration :ivar core_network_technology: The core network technology generation (5G core or EPC / 4G - core). Known values are: "5GC", "EPC". + core). Known values are: "5GC" and "EPC". :vartype core_network_technology: str or ~azure.mgmt.mobilenetwork.models.CoreNetworkType :ivar version: The version of the packet core software that is deployed. :vartype version: str - :ivar control_plane_access_interface: Required. The control plane interface on the access - network. For 5G networks, this is the N2 interface. For 4G networks, this is the S1-MME - interface. + :ivar rollback_version: The previous version of the packet core software that was deployed. + Used when performing the rollback action. + :vartype rollback_version: str + :ivar control_plane_access_interface: The control plane interface on the access network. For 5G + networks, this is the N2 interface. For 4G networks, this is the S1-MME interface. Required. :vartype control_plane_access_interface: ~azure.mgmt.mobilenetwork.models.InterfaceProperties - :ivar sku: Required. The SKU defining the throughput and SIM allowances for this packet core - control plane deployment. Known values are: "EvaluationPackage", "FlagshipStarterPackage", - "EdgeSite2GBPS", "EdgeSite3GBPS", "EdgeSite4GBPS", "MediumPackage", "LargePackage". + :ivar sku: The SKU defining the throughput and SIM allowances for this packet core control + plane deployment. Required. Known values are: "G0", "G1", "G2", "G3", "G4", "G5", and "G10". :vartype sku: str or ~azure.mgmt.mobilenetwork.models.BillingSku + :ivar ue_mtu: The MTU (in bytes) signaled to the UE. The same MTU is set on the user plane data + links for all data networks. The MTU set on the user plane access link is calculated to be 60 + bytes greater than this value to allow for GTP encapsulation. + :vartype ue_mtu: int :ivar local_diagnostics_access: The kubernetes ingress configuration to control access to - packet core diagnostics over local APIs. + packet core diagnostics over local APIs. Required. :vartype local_diagnostics_access: ~azure.mgmt.mobilenetwork.models.LocalDiagnosticsAccessConfiguration :ivar interop_settings: Settings to allow interoperability with third party components e.g. RANs and UEs. - :vartype interop_settings: any + :vartype interop_settings: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'mobile_network': {'required': True}, - 'control_plane_access_interface': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "installation": {"readonly": True}, + "sites": {"required": True, "min_items": 1, "unique": True}, + "platform": {"required": True}, + "rollback_version": {"readonly": True}, + "control_plane_access_interface": {"required": True}, + "sku": {"required": True}, + "ue_mtu": {"maximum": 1930, "minimum": 1280}, + "local_diagnostics_access": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'mobile_network': {'key': 'properties.mobileNetwork', 'type': 'MobileNetworkResourceId'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformConfiguration'}, - 'core_network_technology': {'key': 'properties.coreNetworkTechnology', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'control_plane_access_interface': {'key': 'properties.controlPlaneAccessInterface', 'type': 'InterfaceProperties'}, - 'sku': {'key': 'properties.sku', 'type': 'str'}, - 'local_diagnostics_access': {'key': 'properties.localDiagnosticsAccess', 'type': 'LocalDiagnosticsAccessConfiguration'}, - 'interop_settings': {'key': 'properties.interopSettings', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "installation": {"key": "properties.installation", "type": "Installation"}, + "sites": {"key": "properties.sites", "type": "[SiteResourceId]"}, + "platform": {"key": "properties.platform", "type": "PlatformConfiguration"}, + "core_network_technology": {"key": "properties.coreNetworkTechnology", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "rollback_version": {"key": "properties.rollbackVersion", "type": "str"}, + "control_plane_access_interface": { + "key": "properties.controlPlaneAccessInterface", + "type": "InterfaceProperties", + }, + "sku": {"key": "properties.sku", "type": "str"}, + "ue_mtu": {"key": "properties.ueMtu", "type": "int"}, + "local_diagnostics_access": { + "key": "properties.localDiagnosticsAccess", + "type": "LocalDiagnosticsAccessConfiguration", + }, + "interop_settings": {"key": "properties.interopSettings", "type": "object"}, } def __init__( self, *, location: str, - mobile_network: "_models.MobileNetworkResourceId", + sites: List["_models.SiteResourceId"], + platform: "_models.PlatformConfiguration", control_plane_access_interface: "_models.InterfaceProperties", sku: Union[str, "_models.BillingSku"], + local_diagnostics_access: "_models.LocalDiagnosticsAccessConfiguration", tags: Optional[Dict[str, str]] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, - platform: Optional["_models.PlatformConfiguration"] = None, - core_network_technology: Optional[Union[str, "_models.CoreNetworkType"]] = None, + core_network_technology: Union[str, "_models.CoreNetworkType"] = "5GC", version: Optional[str] = None, - local_diagnostics_access: Optional["_models.LocalDiagnosticsAccessConfiguration"] = None, - interop_settings: Optional[Any] = None, + ue_mtu: int = 1440, + interop_settings: Optional[JSON] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity used to retrieve the ingress certificate from Azure key vault. :paramtype identity: ~azure.mgmt.mobilenetwork.models.ManagedServiceIdentity - :keyword mobile_network: Required. Mobile network in which this packet core control plane is - deployed. - :paramtype mobile_network: ~azure.mgmt.mobilenetwork.models.MobileNetworkResourceId - :keyword platform: The platform where the packet core is deployed. + :keyword sites: Site(s) under which this packet core control plane should be deployed. The + sites must be in the same location as the packet core control plane. Required. + :paramtype sites: list[~azure.mgmt.mobilenetwork.models.SiteResourceId] + :keyword platform: The platform where the packet core is deployed. Required. :paramtype platform: ~azure.mgmt.mobilenetwork.models.PlatformConfiguration :keyword core_network_technology: The core network technology generation (5G core or EPC / 4G - core). Known values are: "5GC", "EPC". + core). Known values are: "5GC" and "EPC". :paramtype core_network_technology: str or ~azure.mgmt.mobilenetwork.models.CoreNetworkType :keyword version: The version of the packet core software that is deployed. :paramtype version: str - :keyword control_plane_access_interface: Required. The control plane interface on the access - network. For 5G networks, this is the N2 interface. For 4G networks, this is the S1-MME - interface. + :keyword control_plane_access_interface: The control plane interface on the access network. For + 5G networks, this is the N2 interface. For 4G networks, this is the S1-MME interface. Required. :paramtype control_plane_access_interface: ~azure.mgmt.mobilenetwork.models.InterfaceProperties - :keyword sku: Required. The SKU defining the throughput and SIM allowances for this packet core - control plane deployment. Known values are: "EvaluationPackage", "FlagshipStarterPackage", - "EdgeSite2GBPS", "EdgeSite3GBPS", "EdgeSite4GBPS", "MediumPackage", "LargePackage". + :keyword sku: The SKU defining the throughput and SIM allowances for this packet core control + plane deployment. Required. Known values are: "G0", "G1", "G2", "G3", "G4", "G5", and "G10". :paramtype sku: str or ~azure.mgmt.mobilenetwork.models.BillingSku + :keyword ue_mtu: The MTU (in bytes) signaled to the UE. The same MTU is set on the user plane + data links for all data networks. The MTU set on the user plane access link is calculated to be + 60 bytes greater than this value to allow for GTP encapsulation. + :paramtype ue_mtu: int :keyword local_diagnostics_access: The kubernetes ingress configuration to control access to - packet core diagnostics over local APIs. + packet core diagnostics over local APIs. Required. :paramtype local_diagnostics_access: ~azure.mgmt.mobilenetwork.models.LocalDiagnosticsAccessConfiguration :keyword interop_settings: Settings to allow interoperability with third party components e.g. RANs and UEs. - :paramtype interop_settings: any + :paramtype interop_settings: JSON """ - super(PacketCoreControlPlane, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.identity = identity self.provisioning_state = None - self.mobile_network = mobile_network + self.installation = None + self.sites = sites self.platform = platform self.core_network_technology = core_network_technology self.version = version + self.rollback_version = None self.control_plane_access_interface = control_plane_access_interface self.sku = sku + self.ue_mtu = ue_mtu self.local_diagnostics_access = local_diagnostics_access self.interop_settings = interop_settings -class PacketCoreControlPlaneListResult(msrest.serialization.Model): +class PacketCoreControlPlaneCollectDiagnosticsPackage(_serialization.Model): + """Packet core control plane collect diagnostics package options. + + All required parameters must be populated in order to send to Azure. + + :ivar storage_account_blob_url: The Storage Account Blob URL to upload the diagnostics package + to. Required. + :vartype storage_account_blob_url: str + """ + + _validation = { + "storage_account_blob_url": {"required": True}, + } + + _attribute_map = { + "storage_account_blob_url": {"key": "storageAccountBlobUrl", "type": "str"}, + } + + def __init__(self, *, storage_account_blob_url: str, **kwargs): + """ + :keyword storage_account_blob_url: The Storage Account Blob URL to upload the diagnostics + package to. Required. + :paramtype storage_account_blob_url: str + """ + super().__init__(**kwargs) + self.storage_account_blob_url = storage_account_blob_url + + +class PacketCoreControlPlaneListResult(_serialization.Model): """Response for packet core control planes API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -1581,25 +2132,20 @@ class PacketCoreControlPlaneListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PacketCoreControlPlane]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PacketCoreControlPlane]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.PacketCoreControlPlane"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PacketCoreControlPlane"]] = None, **kwargs): """ :keyword value: A list of packet core control planes in a resource group. :paramtype value: list[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] """ - super(PacketCoreControlPlaneListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -1623,26 +2169,22 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class PacketCoreControlPlaneVersion(ProxyResource): @@ -1663,56 +2205,40 @@ class PacketCoreControlPlaneVersion(ProxyResource): :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData :ivar provisioning_state: The provisioning state of the packet core control plane version resource. Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", - "Canceled", "Deleted". + "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar version_state: The state of this packet core control plane version. Known values are: - "Unknown", "Preview", "Validating", "ValidationFailed", "Active", "Deprecated". - :vartype version_state: str or ~azure.mgmt.mobilenetwork.models.VersionState - :ivar recommended_version: Indicates whether this is the recommended version to use for new - packet core control plane deployments. Known values are: "Recommended", "NotRecommended". - :vartype recommended_version: str or ~azure.mgmt.mobilenetwork.models.RecommendedVersion + :ivar platforms: Platform specific packet core control plane version properties. + :vartype platforms: list[~azure.mgmt.mobilenetwork.models.Platform] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'version_state': {'key': 'properties.versionState', 'type': 'str'}, - 'recommended_version': {'key': 'properties.recommendedVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "platforms": {"key": "properties.platforms", "type": "[Platform]"}, } - def __init__( - self, - *, - version_state: Optional[Union[str, "_models.VersionState"]] = None, - recommended_version: Optional[Union[str, "_models.RecommendedVersion"]] = None, - **kwargs - ): + def __init__(self, *, platforms: Optional[List["_models.Platform"]] = None, **kwargs): """ - :keyword version_state: The state of this packet core control plane version. Known values are: - "Unknown", "Preview", "Validating", "ValidationFailed", "Active", "Deprecated". - :paramtype version_state: str or ~azure.mgmt.mobilenetwork.models.VersionState - :keyword recommended_version: Indicates whether this is the recommended version to use for new - packet core control plane deployments. Known values are: "Recommended", "NotRecommended". - :paramtype recommended_version: str or ~azure.mgmt.mobilenetwork.models.RecommendedVersion + :keyword platforms: Platform specific packet core control plane version properties. + :paramtype platforms: list[~azure.mgmt.mobilenetwork.models.Platform] """ - super(PacketCoreControlPlaneVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None - self.version_state = version_state - self.recommended_version = recommended_version + self.platforms = platforms -class PacketCoreControlPlaneVersionListResult(msrest.serialization.Model): +class PacketCoreControlPlaneVersionListResult(_serialization.Model): """Response for packet core control plane version API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -1724,31 +2250,26 @@ class PacketCoreControlPlaneVersionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PacketCoreControlPlaneVersion]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PacketCoreControlPlaneVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.PacketCoreControlPlaneVersion"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PacketCoreControlPlaneVersion"]] = None, **kwargs): """ :keyword value: A list of supported packet core control plane versions. :paramtype value: list[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneVersion] """ - super(PacketCoreControlPlaneVersionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None class PacketCoreDataPlane(TrackedResource): - """Packet core data plane resource. + """Packet core data plane resource. Must be created in the same location as its parent packet core control plane. Variables are only populated by the server, and will be ignored when sending a request. @@ -1765,37 +2286,38 @@ class PacketCoreDataPlane(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the packet core data plane resource. Known - values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and + "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar user_plane_access_interface: Required. The user plane interface on the access network. - For 5G networks, this is the N3 interface. For 4G networks, this is the S1-U interface. + :ivar user_plane_access_interface: The user plane interface on the access network. For 5G + networks, this is the N3 interface. For 4G networks, this is the S1-U interface. Required. :vartype user_plane_access_interface: ~azure.mgmt.mobilenetwork.models.InterfaceProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'user_plane_access_interface': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "user_plane_access_interface": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'user_plane_access_interface': {'key': 'properties.userPlaneAccessInterface', 'type': 'InterfaceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "user_plane_access_interface": {"key": "properties.userPlaneAccessInterface", "type": "InterfaceProperties"}, } def __init__( @@ -1807,20 +2329,20 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword user_plane_access_interface: Required. The user plane interface on the access network. - For 5G networks, this is the N3 interface. For 4G networks, this is the S1-U interface. + :keyword user_plane_access_interface: The user plane interface on the access network. For 5G + networks, this is the N3 interface. For 4G networks, this is the S1-U interface. Required. :paramtype user_plane_access_interface: ~azure.mgmt.mobilenetwork.models.InterfaceProperties """ - super(PacketCoreDataPlane, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None self.user_plane_access_interface = user_plane_access_interface -class PacketCoreDataPlaneListResult(msrest.serialization.Model): +class PacketCoreDataPlaneListResult(_serialization.Model): """Response for packet core data planes API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -1832,67 +2354,66 @@ class PacketCoreDataPlaneListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PacketCoreDataPlane]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PacketCoreDataPlane]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.PacketCoreDataPlane"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PacketCoreDataPlane"]] = None, **kwargs): """ :keyword value: A list of packet core data planes in a resource group. :paramtype value: list[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] """ - super(PacketCoreDataPlaneListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class PccRuleConfiguration(msrest.serialization.Model): +class PccRuleConfiguration(_serialization.Model): """Data flow policy rule configuration. All required parameters must be populated in order to send to Azure. - :ivar rule_name: Required. The name of the rule. This must be unique within the parent service. - You must not use any of the following reserved strings - ``default``\ , ``requested`` or - ``service``. + :ivar rule_name: The name of the rule. This must be unique within the parent service. You must + not use any of the following reserved strings - ``default``\ , ``requested`` or ``service``. + Required. :vartype rule_name: str - :ivar rule_precedence: Required. A precedence value that is used to decide between data flow - policy rules when identifying the QoS values to use for a particular SIM. A lower value means a - higher priority. This value should be unique among all data flow policy rules configured in the - mobile network. + :ivar rule_precedence: A precedence value that is used to decide between data flow policy rules + when identifying the QoS values to use for a particular SIM. A lower value means a higher + priority. This value should be unique among all data flow policy rules configured in the mobile + network. Required. :vartype rule_precedence: int :ivar rule_qos_policy: The QoS policy to use for packets matching this rule. If this field is null then the parent service will define the QoS settings. :vartype rule_qos_policy: ~azure.mgmt.mobilenetwork.models.PccRuleQosPolicy :ivar traffic_control: Determines whether flows that match this data flow policy rule are - permitted. Known values are: "Enabled", "Blocked". + permitted. Known values are: "Enabled" and "Blocked". :vartype traffic_control: str or ~azure.mgmt.mobilenetwork.models.TrafficControlPermission - :ivar service_data_flow_templates: Required. The set of data flow templates to use for this - data flow policy rule. + :ivar service_data_flow_templates: The set of data flow templates to use for this data flow + policy rule. Required. :vartype service_data_flow_templates: list[~azure.mgmt.mobilenetwork.models.ServiceDataFlowTemplate] """ _validation = { - 'rule_name': {'required': True, 'max_length': 64, 'min_length': 0, 'pattern': r'^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$'}, - 'rule_precedence': {'required': True, 'maximum': 255, 'minimum': 0}, - 'service_data_flow_templates': {'required': True, 'min_items': 1, 'unique': True}, + "rule_name": { + "required": True, + "max_length": 64, + "pattern": r"^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$", + }, + "rule_precedence": {"required": True, "maximum": 255, "minimum": 0}, + "service_data_flow_templates": {"required": True, "min_items": 1, "unique": True}, } _attribute_map = { - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'rule_precedence': {'key': 'rulePrecedence', 'type': 'int'}, - 'rule_qos_policy': {'key': 'ruleQosPolicy', 'type': 'PccRuleQosPolicy'}, - 'traffic_control': {'key': 'trafficControl', 'type': 'str'}, - 'service_data_flow_templates': {'key': 'serviceDataFlowTemplates', 'type': '[ServiceDataFlowTemplate]'}, + "rule_name": {"key": "ruleName", "type": "str"}, + "rule_precedence": {"key": "rulePrecedence", "type": "int"}, + "rule_qos_policy": {"key": "ruleQosPolicy", "type": "PccRuleQosPolicy"}, + "traffic_control": {"key": "trafficControl", "type": "str"}, + "service_data_flow_templates": {"key": "serviceDataFlowTemplates", "type": "[ServiceDataFlowTemplate]"}, } def __init__( @@ -1906,27 +2427,27 @@ def __init__( **kwargs ): """ - :keyword rule_name: Required. The name of the rule. This must be unique within the parent - service. You must not use any of the following reserved strings - ``default``\ , ``requested`` - or ``service``. + :keyword rule_name: The name of the rule. This must be unique within the parent service. You + must not use any of the following reserved strings - ``default``\ , ``requested`` or + ``service``. Required. :paramtype rule_name: str - :keyword rule_precedence: Required. A precedence value that is used to decide between data flow - policy rules when identifying the QoS values to use for a particular SIM. A lower value means a - higher priority. This value should be unique among all data flow policy rules configured in the - mobile network. + :keyword rule_precedence: A precedence value that is used to decide between data flow policy + rules when identifying the QoS values to use for a particular SIM. A lower value means a higher + priority. This value should be unique among all data flow policy rules configured in the mobile + network. Required. :paramtype rule_precedence: int :keyword rule_qos_policy: The QoS policy to use for packets matching this rule. If this field is null then the parent service will define the QoS settings. :paramtype rule_qos_policy: ~azure.mgmt.mobilenetwork.models.PccRuleQosPolicy :keyword traffic_control: Determines whether flows that match this data flow policy rule are - permitted. Known values are: "Enabled", "Blocked". + permitted. Known values are: "Enabled" and "Blocked". :paramtype traffic_control: str or ~azure.mgmt.mobilenetwork.models.TrafficControlPermission - :keyword service_data_flow_templates: Required. The set of data flow templates to use for this - data flow policy rule. + :keyword service_data_flow_templates: The set of data flow templates to use for this data flow + policy rule. Required. :paramtype service_data_flow_templates: list[~azure.mgmt.mobilenetwork.models.ServiceDataFlowTemplate] """ - super(PccRuleConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_name = rule_name self.rule_precedence = rule_precedence self.rule_qos_policy = rule_qos_policy @@ -1934,7 +2455,7 @@ def __init__( self.service_data_flow_templates = service_data_flow_templates -class QosPolicy(msrest.serialization.Model): +class QosPolicy(_serialization.Model): """QoS policy. All required parameters must be populated in order to send to Azure. @@ -1955,31 +2476,31 @@ class QosPolicy(msrest.serialization.Model): :ivar preemption_capability: QoS Flow preemption capability. The preemption capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known values are: - "NotPreempt", "MayPreempt". + "NotPreempt" and "MayPreempt". :vartype preemption_capability: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability :ivar preemption_vulnerability: QoS Flow preemption vulnerability. The preemption vulnerability of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known values - are: "NotPreemptable", "Preemptable". + are: "NotPreemptable" and "Preemptable". :vartype preemption_vulnerability: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability - :ivar maximum_bit_rate: Required. The maximum bit rate (MBR) for all service data flows that - use this data flow policy rule or service. + :ivar maximum_bit_rate: The maximum bit rate (MBR) for all service data flows that use this + data flow policy rule or service. Required. :vartype maximum_bit_rate: ~azure.mgmt.mobilenetwork.models.Ambr """ _validation = { - 'five_qi': {'maximum': 127, 'minimum': 1}, - 'allocation_and_retention_priority_level': {'maximum': 15, 'minimum': 1}, - 'maximum_bit_rate': {'required': True}, + "five_qi": {"maximum": 127, "minimum": 1}, + "allocation_and_retention_priority_level": {"maximum": 15, "minimum": 1}, + "maximum_bit_rate": {"required": True}, } _attribute_map = { - 'five_qi': {'key': '5qi', 'type': 'int'}, - 'allocation_and_retention_priority_level': {'key': 'allocationAndRetentionPriorityLevel', 'type': 'int'}, - 'preemption_capability': {'key': 'preemptionCapability', 'type': 'str'}, - 'preemption_vulnerability': {'key': 'preemptionVulnerability', 'type': 'str'}, - 'maximum_bit_rate': {'key': 'maximumBitRate', 'type': 'Ambr'}, + "five_qi": {"key": "5qi", "type": "int"}, + "allocation_and_retention_priority_level": {"key": "allocationAndRetentionPriorityLevel", "type": "int"}, + "preemption_capability": {"key": "preemptionCapability", "type": "str"}, + "preemption_vulnerability": {"key": "preemptionVulnerability", "type": "str"}, + "maximum_bit_rate": {"key": "maximumBitRate", "type": "Ambr"}, } def __init__( @@ -2009,19 +2530,19 @@ def __init__( :keyword preemption_capability: QoS Flow preemption capability. The preemption capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known values are: - "NotPreempt", "MayPreempt". + "NotPreempt" and "MayPreempt". :paramtype preemption_capability: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability :keyword preemption_vulnerability: QoS Flow preemption vulnerability. The preemption vulnerability of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. - Known values are: "NotPreemptable", "Preemptable". + Known values are: "NotPreemptable" and "Preemptable". :paramtype preemption_vulnerability: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability - :keyword maximum_bit_rate: Required. The maximum bit rate (MBR) for all service data flows that - use this data flow policy rule or service. + :keyword maximum_bit_rate: The maximum bit rate (MBR) for all service data flows that use this + data flow policy rule or service. Required. :paramtype maximum_bit_rate: ~azure.mgmt.mobilenetwork.models.Ambr """ - super(QosPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.five_qi = five_qi self.allocation_and_retention_priority_level = allocation_and_retention_priority_level self.preemption_capability = preemption_capability @@ -2050,16 +2571,16 @@ class PccRuleQosPolicy(QosPolicy): :ivar preemption_capability: QoS Flow preemption capability. The preemption capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known values are: - "NotPreempt", "MayPreempt". + "NotPreempt" and "MayPreempt". :vartype preemption_capability: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability :ivar preemption_vulnerability: QoS Flow preemption vulnerability. The preemption vulnerability of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known values - are: "NotPreemptable", "Preemptable". + are: "NotPreemptable" and "Preemptable". :vartype preemption_vulnerability: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability - :ivar maximum_bit_rate: Required. The maximum bit rate (MBR) for all service data flows that - use this data flow policy rule or service. + :ivar maximum_bit_rate: The maximum bit rate (MBR) for all service data flows that use this + data flow policy rule or service. Required. :vartype maximum_bit_rate: ~azure.mgmt.mobilenetwork.models.Ambr :ivar guaranteed_bit_rate: The guaranteed bit rate (GBR) for all service data flows that use this data flow policy rule. This is an optional setting. If you do not provide a value, there @@ -2068,18 +2589,18 @@ class PccRuleQosPolicy(QosPolicy): """ _validation = { - 'five_qi': {'maximum': 127, 'minimum': 1}, - 'allocation_and_retention_priority_level': {'maximum': 15, 'minimum': 1}, - 'maximum_bit_rate': {'required': True}, + "five_qi": {"maximum": 127, "minimum": 1}, + "allocation_and_retention_priority_level": {"maximum": 15, "minimum": 1}, + "maximum_bit_rate": {"required": True}, } _attribute_map = { - 'five_qi': {'key': '5qi', 'type': 'int'}, - 'allocation_and_retention_priority_level': {'key': 'allocationAndRetentionPriorityLevel', 'type': 'int'}, - 'preemption_capability': {'key': 'preemptionCapability', 'type': 'str'}, - 'preemption_vulnerability': {'key': 'preemptionVulnerability', 'type': 'str'}, - 'maximum_bit_rate': {'key': 'maximumBitRate', 'type': 'Ambr'}, - 'guaranteed_bit_rate': {'key': 'guaranteedBitRate', 'type': 'Ambr'}, + "five_qi": {"key": "5qi", "type": "int"}, + "allocation_and_retention_priority_level": {"key": "allocationAndRetentionPriorityLevel", "type": "int"}, + "preemption_capability": {"key": "preemptionCapability", "type": "str"}, + "preemption_vulnerability": {"key": "preemptionVulnerability", "type": "str"}, + "maximum_bit_rate": {"key": "maximumBitRate", "type": "Ambr"}, + "guaranteed_bit_rate": {"key": "guaranteedBitRate", "type": "Ambr"}, } def __init__( @@ -2110,90 +2631,167 @@ def __init__( :keyword preemption_capability: QoS Flow preemption capability. The preemption capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Known values are: - "NotPreempt", "MayPreempt". + "NotPreempt" and "MayPreempt". :paramtype preemption_capability: str or ~azure.mgmt.mobilenetwork.models.PreemptionCapability :keyword preemption_vulnerability: QoS Flow preemption vulnerability. The preemption vulnerability of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. - Known values are: "NotPreemptable", "Preemptable". + Known values are: "NotPreemptable" and "Preemptable". :paramtype preemption_vulnerability: str or ~azure.mgmt.mobilenetwork.models.PreemptionVulnerability - :keyword maximum_bit_rate: Required. The maximum bit rate (MBR) for all service data flows that - use this data flow policy rule or service. + :keyword maximum_bit_rate: The maximum bit rate (MBR) for all service data flows that use this + data flow policy rule or service. Required. :paramtype maximum_bit_rate: ~azure.mgmt.mobilenetwork.models.Ambr :keyword guaranteed_bit_rate: The guaranteed bit rate (GBR) for all service data flows that use this data flow policy rule. This is an optional setting. If you do not provide a value, there will be no GBR set for the data flow policy rule that uses this QoS definition. :paramtype guaranteed_bit_rate: ~azure.mgmt.mobilenetwork.models.Ambr """ - super(PccRuleQosPolicy, self).__init__(five_qi=five_qi, allocation_and_retention_priority_level=allocation_and_retention_priority_level, preemption_capability=preemption_capability, preemption_vulnerability=preemption_vulnerability, maximum_bit_rate=maximum_bit_rate, **kwargs) + super().__init__( + five_qi=five_qi, + allocation_and_retention_priority_level=allocation_and_retention_priority_level, + preemption_capability=preemption_capability, + preemption_vulnerability=preemption_vulnerability, + maximum_bit_rate=maximum_bit_rate, + **kwargs + ) self.guaranteed_bit_rate = guaranteed_bit_rate -class PinholeTimeouts(msrest.serialization.Model): +class PinholeTimeouts(_serialization.Model): """Expiry times of inactive NAPT pinholes, in seconds. All timers must be at least 1 second. - :ivar tcp: Pinhole timeout for TCP pinholes in seconds. Default for TCP is 2 hours 4 minutes, - as per RFC 5382 section 5. + :ivar tcp: Pinhole timeout for TCP pinholes in seconds. Default for TCP is 3 minutes. :vartype tcp: int - :ivar udp: Pinhole timeout for UDP pinholes in seconds. Default for UDP is 5 minutes, as per - RFC 4787 section 4.3. + :ivar udp: Pinhole timeout for UDP pinholes in seconds. Default for UDP is 30 seconds. :vartype udp: int - :ivar icmp: Pinhole timeout for ICMP pinholes in seconds. Default for ICMP Echo is 60 seconds, - as per RFC 5508 section 3.2. + :ivar icmp: Pinhole timeout for ICMP pinholes in seconds. Default for ICMP Echo is 30 seconds. :vartype icmp: int """ _validation = { - 'tcp': {'minimum': 1}, - 'udp': {'minimum': 1}, - 'icmp': {'minimum': 1}, + "tcp": {"minimum": 1}, + "udp": {"minimum": 1}, + "icmp": {"minimum": 1}, } _attribute_map = { - 'tcp': {'key': 'tcp', 'type': 'int'}, - 'udp': {'key': 'udp', 'type': 'int'}, - 'icmp': {'key': 'icmp', 'type': 'int'}, + "tcp": {"key": "tcp", "type": "int"}, + "udp": {"key": "udp", "type": "int"}, + "icmp": {"key": "icmp", "type": "int"}, } - def __init__( - self, - *, - tcp: Optional[int] = 180, - udp: Optional[int] = 30, - icmp: Optional[int] = 30, - **kwargs - ): + def __init__(self, *, tcp: int = 180, udp: int = 30, icmp: int = 30, **kwargs): """ - :keyword tcp: Pinhole timeout for TCP pinholes in seconds. Default for TCP is 2 hours 4 - minutes, as per RFC 5382 section 5. + :keyword tcp: Pinhole timeout for TCP pinholes in seconds. Default for TCP is 3 minutes. :paramtype tcp: int - :keyword udp: Pinhole timeout for UDP pinholes in seconds. Default for UDP is 5 minutes, as per - RFC 4787 section 4.3. + :keyword udp: Pinhole timeout for UDP pinholes in seconds. Default for UDP is 30 seconds. :paramtype udp: int - :keyword icmp: Pinhole timeout for ICMP pinholes in seconds. Default for ICMP Echo is 60 - seconds, as per RFC 5508 section 3.2. + :keyword icmp: Pinhole timeout for ICMP pinholes in seconds. Default for ICMP Echo is 30 + seconds. :paramtype icmp: int """ - super(PinholeTimeouts, self).__init__(**kwargs) + super().__init__(**kwargs) self.tcp = tcp self.udp = udp self.icmp = icmp -class PlatformConfiguration(msrest.serialization.Model): +class Platform(_serialization.Model): + """Platform specific packet core control plane version properties. + + :ivar platform_type: The platform type where this version can be deployed. Known values are: + "AKS-HCI" and "3P-AZURE-STACK-HCI". + :vartype platform_type: str or ~azure.mgmt.mobilenetwork.models.PlatformType + :ivar version_state: The state of this packet core control plane version on this platform. + Known values are: "Unknown", "Preview", "Validating", "ValidationFailed", "Active", and + "Deprecated". + :vartype version_state: str or ~azure.mgmt.mobilenetwork.models.VersionState + :ivar minimum_platform_software_version: The minimum software version of the platform where + this packet core version can be deployed. + :vartype minimum_platform_software_version: str + :ivar maximum_platform_software_version: The maximum software version of the platform where + this packet core version can be deployed. + :vartype maximum_platform_software_version: str + :ivar recommended_version: Indicates whether this is the recommended version for this platform. + Known values are: "Recommended" and "NotRecommended". + :vartype recommended_version: str or ~azure.mgmt.mobilenetwork.models.RecommendedVersion + :ivar obsolete_version: Indicates whether this version is obsoleted for this platform. Known + values are: "Obsolete" and "NotObsolete". + :vartype obsolete_version: str or ~azure.mgmt.mobilenetwork.models.ObsoleteVersion + """ + + _attribute_map = { + "platform_type": {"key": "platformType", "type": "str"}, + "version_state": {"key": "versionState", "type": "str"}, + "minimum_platform_software_version": {"key": "minimumPlatformSoftwareVersion", "type": "str"}, + "maximum_platform_software_version": {"key": "maximumPlatformSoftwareVersion", "type": "str"}, + "recommended_version": {"key": "recommendedVersion", "type": "str"}, + "obsolete_version": {"key": "obsoleteVersion", "type": "str"}, + } + + def __init__( + self, + *, + platform_type: Optional[Union[str, "_models.PlatformType"]] = None, + version_state: Optional[Union[str, "_models.VersionState"]] = None, + minimum_platform_software_version: Optional[str] = None, + maximum_platform_software_version: Optional[str] = None, + recommended_version: Optional[Union[str, "_models.RecommendedVersion"]] = None, + obsolete_version: Optional[Union[str, "_models.ObsoleteVersion"]] = None, + **kwargs + ): + """ + :keyword platform_type: The platform type where this version can be deployed. Known values are: + "AKS-HCI" and "3P-AZURE-STACK-HCI". + :paramtype platform_type: str or ~azure.mgmt.mobilenetwork.models.PlatformType + :keyword version_state: The state of this packet core control plane version on this platform. + Known values are: "Unknown", "Preview", "Validating", "ValidationFailed", "Active", and + "Deprecated". + :paramtype version_state: str or ~azure.mgmt.mobilenetwork.models.VersionState + :keyword minimum_platform_software_version: The minimum software version of the platform where + this packet core version can be deployed. + :paramtype minimum_platform_software_version: str + :keyword maximum_platform_software_version: The maximum software version of the platform where + this packet core version can be deployed. + :paramtype maximum_platform_software_version: str + :keyword recommended_version: Indicates whether this is the recommended version for this + platform. Known values are: "Recommended" and "NotRecommended". + :paramtype recommended_version: str or ~azure.mgmt.mobilenetwork.models.RecommendedVersion + :keyword obsolete_version: Indicates whether this version is obsoleted for this platform. Known + values are: "Obsolete" and "NotObsolete". + :paramtype obsolete_version: str or ~azure.mgmt.mobilenetwork.models.ObsoleteVersion + """ + super().__init__(**kwargs) + self.platform_type = platform_type + self.version_state = version_state + self.minimum_platform_software_version = minimum_platform_software_version + self.maximum_platform_software_version = maximum_platform_software_version + self.recommended_version = recommended_version + self.obsolete_version = obsolete_version + + +class PlatformConfiguration(_serialization.Model): """The platform where the packet core is deployed. + 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. - :ivar type: Required. The platform type where packet core is deployed. Known values are: - "AKS-HCI", "BaseVM". + :ivar type: The platform type where packet core is deployed. Required. Known values are: + "AKS-HCI" and "3P-AZURE-STACK-HCI". :vartype type: str or ~azure.mgmt.mobilenetwork.models.PlatformType - :ivar azure_stack_edge_device: The Azure Stack Edge device where where the packet core is - deployed. If the device is part of a fault tolerant pair, either device in the pair can be - specified. + :ivar azure_stack_edge_device: The Azure Stack Edge device where the packet core is deployed. + If the device is part of a fault tolerant pair, either device in the pair can be specified. :vartype azure_stack_edge_device: ~azure.mgmt.mobilenetwork.models.AzureStackEdgeDeviceResourceId + :ivar azure_stack_edge_devices: The Azure Stack Edge devices where the packet core is deployed. + If the packet core is deployed across multiple devices, all devices will appear in this list. + :vartype azure_stack_edge_devices: + list[~azure.mgmt.mobilenetwork.models.AzureStackEdgeDeviceResourceId] + :ivar azure_stack_hci_cluster: The Azure Stack HCI cluster where the packet core is deployed. + :vartype azure_stack_hci_cluster: + ~azure.mgmt.mobilenetwork.models.AzureStackHCIClusterResourceId :ivar connected_cluster: Azure Arc connected cluster where the packet core is deployed. :vartype connected_cluster: ~azure.mgmt.mobilenetwork.models.ConnectedClusterResourceId :ivar custom_location: Azure Arc custom location where the packet core is deployed. @@ -2201,14 +2799,17 @@ class PlatformConfiguration(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, + "azure_stack_edge_devices": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'azure_stack_edge_device': {'key': 'azureStackEdgeDevice', 'type': 'AzureStackEdgeDeviceResourceId'}, - 'connected_cluster': {'key': 'connectedCluster', 'type': 'ConnectedClusterResourceId'}, - 'custom_location': {'key': 'customLocation', 'type': 'CustomLocationResourceId'}, + "type": {"key": "type", "type": "str"}, + "azure_stack_edge_device": {"key": "azureStackEdgeDevice", "type": "AzureStackEdgeDeviceResourceId"}, + "azure_stack_edge_devices": {"key": "azureStackEdgeDevices", "type": "[AzureStackEdgeDeviceResourceId]"}, + "azure_stack_hci_cluster": {"key": "azureStackHciCluster", "type": "AzureStackHCIClusterResourceId"}, + "connected_cluster": {"key": "connectedCluster", "type": "ConnectedClusterResourceId"}, + "custom_location": {"key": "customLocation", "type": "CustomLocationResourceId"}, } def __init__( @@ -2216,110 +2817,105 @@ def __init__( *, type: Union[str, "_models.PlatformType"], azure_stack_edge_device: Optional["_models.AzureStackEdgeDeviceResourceId"] = None, + azure_stack_hci_cluster: Optional["_models.AzureStackHCIClusterResourceId"] = None, connected_cluster: Optional["_models.ConnectedClusterResourceId"] = None, custom_location: Optional["_models.CustomLocationResourceId"] = None, **kwargs ): """ - :keyword type: Required. The platform type where packet core is deployed. Known values are: - "AKS-HCI", "BaseVM". + :keyword type: The platform type where packet core is deployed. Required. Known values are: + "AKS-HCI" and "3P-AZURE-STACK-HCI". :paramtype type: str or ~azure.mgmt.mobilenetwork.models.PlatformType - :keyword azure_stack_edge_device: The Azure Stack Edge device where where the packet core is + :keyword azure_stack_edge_device: The Azure Stack Edge device where the packet core is deployed. If the device is part of a fault tolerant pair, either device in the pair can be specified. :paramtype azure_stack_edge_device: ~azure.mgmt.mobilenetwork.models.AzureStackEdgeDeviceResourceId + :keyword azure_stack_hci_cluster: The Azure Stack HCI cluster where the packet core is + deployed. + :paramtype azure_stack_hci_cluster: + ~azure.mgmt.mobilenetwork.models.AzureStackHCIClusterResourceId :keyword connected_cluster: Azure Arc connected cluster where the packet core is deployed. :paramtype connected_cluster: ~azure.mgmt.mobilenetwork.models.ConnectedClusterResourceId :keyword custom_location: Azure Arc custom location where the packet core is deployed. :paramtype custom_location: ~azure.mgmt.mobilenetwork.models.CustomLocationResourceId """ - super(PlatformConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.azure_stack_edge_device = azure_stack_edge_device + self.azure_stack_edge_devices = None + self.azure_stack_hci_cluster = azure_stack_hci_cluster self.connected_cluster = connected_cluster self.custom_location = custom_location -class PlmnId(msrest.serialization.Model): +class PlmnId(_serialization.Model): """Public land mobile network (PLMN) ID. All required parameters must be populated in order to send to Azure. - :ivar mcc: Required. Mobile country code (MCC). + :ivar mcc: Mobile country code (MCC). Required. :vartype mcc: str - :ivar mnc: Required. Mobile network code (MNC). + :ivar mnc: Mobile network code (MNC). Required. :vartype mnc: str """ _validation = { - 'mcc': {'required': True, 'pattern': r'^\d{3}$'}, - 'mnc': {'required': True, 'pattern': r'^\d{2,3}$'}, + "mcc": {"required": True, "pattern": r"^\d{3}$"}, + "mnc": {"required": True, "pattern": r"^\d{2,3}$"}, } _attribute_map = { - 'mcc': {'key': 'mcc', 'type': 'str'}, - 'mnc': {'key': 'mnc', 'type': 'str'}, + "mcc": {"key": "mcc", "type": "str"}, + "mnc": {"key": "mnc", "type": "str"}, } - def __init__( - self, - *, - mcc: str, - mnc: str, - **kwargs - ): + def __init__(self, *, mcc: str, mnc: str, **kwargs): """ - :keyword mcc: Required. Mobile country code (MCC). + :keyword mcc: Mobile country code (MCC). Required. :paramtype mcc: str - :keyword mnc: Required. Mobile network code (MNC). + :keyword mnc: Mobile network code (MNC). Required. :paramtype mnc: str """ - super(PlmnId, self).__init__(**kwargs) + super().__init__(**kwargs) self.mcc = mcc self.mnc = mnc -class PortRange(msrest.serialization.Model): +class PortRange(_serialization.Model): """Range of port numbers to use as translated ports on each translated address. -If not specified and NAPT is enabled, this range defaults to 1,024 - 49,999. -(Ports under 1,024 should not be used because these are special purpose ports reserved by IANA. Ports 50,000 and above are reserved for non-NAPT use.). + If not specified and NAPT is enabled, this range defaults to 1,024 - 49,999. + (Ports under 1,024 should not be used because these are special purpose ports reserved by IANA. Ports 50,000 and above are reserved for non-NAPT use.). - :ivar min_port: The minimum port number. - :vartype min_port: int - :ivar max_port: The maximum port number. - :vartype max_port: int + :ivar min_port: The minimum port number. + :vartype min_port: int + :ivar max_port: The maximum port number. + :vartype max_port: int """ _validation = { - 'min_port': {'maximum': 65535, 'minimum': 1024}, - 'max_port': {'maximum': 65535, 'minimum': 1024}, + "min_port": {"maximum": 65535, "minimum": 1024}, + "max_port": {"maximum": 65535, "minimum": 1024}, } _attribute_map = { - 'min_port': {'key': 'minPort', 'type': 'int'}, - 'max_port': {'key': 'maxPort', 'type': 'int'}, + "min_port": {"key": "minPort", "type": "int"}, + "max_port": {"key": "maxPort", "type": "int"}, } - def __init__( - self, - *, - min_port: Optional[int] = 1024, - max_port: Optional[int] = 49999, - **kwargs - ): + def __init__(self, *, min_port: int = 1024, max_port: int = 49999, **kwargs): """ :keyword min_port: The minimum port number. :paramtype min_port: int :keyword max_port: The maximum port number. :paramtype max_port: int """ - super(PortRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.min_port = min_port self.max_port = max_port -class PortReuseHoldTimes(msrest.serialization.Model): +class PortReuseHoldTimes(_serialization.Model): """The minimum time (in seconds) that will pass before a port that was used by a closed pinhole can be recycled for use by another pinhole. All hold times must be minimum 1 second. :ivar tcp: Minimum time in seconds that will pass before a TCP port that was used by a closed @@ -2331,22 +2927,16 @@ class PortReuseHoldTimes(msrest.serialization.Model): """ _validation = { - 'tcp': {'minimum': 1}, - 'udp': {'minimum': 1}, + "tcp": {"minimum": 1}, + "udp": {"minimum": 1}, } _attribute_map = { - 'tcp': {'key': 'tcp', 'type': 'int'}, - 'udp': {'key': 'udp', 'type': 'int'}, + "tcp": {"key": "tcp", "type": "int"}, + "udp": {"key": "udp", "type": "int"}, } - def __init__( - self, - *, - tcp: Optional[int] = 120, - udp: Optional[int] = 60, - **kwargs - ): + def __init__(self, *, tcp: int = 120, udp: int = 60, **kwargs): """ :keyword tcp: Minimum time in seconds that will pass before a TCP port that was used by a closed pinhole can be reused. Default for TCP is 2 minutes. @@ -2355,13 +2945,13 @@ def __init__( closed pinhole can be reused. Default for UDP is 1 minute. :paramtype udp: int """ - super(PortReuseHoldTimes, self).__init__(**kwargs) + super().__init__(**kwargs) self.tcp = tcp self.udp = udp class Service(TrackedResource): - """Service resource. + """Service resource. Must be created in the same location as its parent mobile network. Variables are only populated by the server, and will be ignored when sending a request. @@ -2378,47 +2968,47 @@ class Service(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the service resource. Known values are: - "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar service_precedence: Required. A precedence value that is used to decide between services - when identifying the QoS values to use for a particular SIM. A lower value means a higher - priority. This value should be unique among all services configured in the mobile network. + :ivar service_precedence: A precedence value that is used to decide between services when + identifying the QoS values to use for a particular SIM. A lower value means a higher priority. + This value should be unique among all services configured in the mobile network. Required. :vartype service_precedence: int :ivar service_qos_policy: The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a PccRuleConfiguration. If this field is null then the UE's SIM policy will define the QoS settings. :vartype service_qos_policy: ~azure.mgmt.mobilenetwork.models.QosPolicy - :ivar pcc_rules: Required. The set of data flow policy rules that make up this service. + :ivar pcc_rules: The set of data flow policy rules that make up this service. Required. :vartype pcc_rules: list[~azure.mgmt.mobilenetwork.models.PccRuleConfiguration] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'service_precedence': {'required': True, 'maximum': 255, 'minimum': 0}, - 'pcc_rules': {'required': True, 'min_items': 1, 'unique': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "service_precedence": {"required": True, "maximum": 255, "minimum": 0}, + "pcc_rules": {"required": True, "min_items": 1, "unique": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'service_precedence': {'key': 'properties.servicePrecedence', 'type': 'int'}, - 'service_qos_policy': {'key': 'properties.serviceQosPolicy', 'type': 'QosPolicy'}, - 'pcc_rules': {'key': 'properties.pccRules', 'type': '[PccRuleConfiguration]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "service_precedence": {"key": "properties.servicePrecedence", "type": "int"}, + "service_qos_policy": {"key": "properties.serviceQosPolicy", "type": "QosPolicy"}, + "pcc_rules": {"key": "properties.pccRules", "type": "[PccRuleConfiguration]"}, } def __init__( @@ -2432,54 +3022,53 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword service_precedence: Required. A precedence value that is used to decide between - services when identifying the QoS values to use for a particular SIM. A lower value means a - higher priority. This value should be unique among all services configured in the mobile - network. + :keyword service_precedence: A precedence value that is used to decide between services when + identifying the QoS values to use for a particular SIM. A lower value means a higher priority. + This value should be unique among all services configured in the mobile network. Required. :paramtype service_precedence: int :keyword service_qos_policy: The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a PccRuleConfiguration. If this field is null then the UE's SIM policy will define the QoS settings. :paramtype service_qos_policy: ~azure.mgmt.mobilenetwork.models.QosPolicy - :keyword pcc_rules: Required. The set of data flow policy rules that make up this service. + :keyword pcc_rules: The set of data flow policy rules that make up this service. Required. :paramtype pcc_rules: list[~azure.mgmt.mobilenetwork.models.PccRuleConfiguration] """ - super(Service, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None self.service_precedence = service_precedence self.service_qos_policy = service_qos_policy self.pcc_rules = pcc_rules -class ServiceDataFlowTemplate(msrest.serialization.Model): +class ServiceDataFlowTemplate(_serialization.Model): """Data flow template. All required parameters must be populated in order to send to Azure. - :ivar template_name: Required. The name of the data flow template. This must be unique within - the parent data flow policy rule. You must not use any of the following reserved strings - - ``default``\ , ``requested`` or ``service``. + :ivar template_name: The name of the data flow template. This must be unique within the parent + data flow policy rule. You must not use any of the following reserved strings - ``default``\ , + ``requested`` or ``service``. Required. :vartype template_name: str - :ivar direction: Required. The direction of this flow. Known values are: "Uplink", "Downlink", - "Bidirectional". + :ivar direction: The direction of this flow. Required. Known values are: "Uplink", "Downlink", + and "Bidirectional". :vartype direction: str or ~azure.mgmt.mobilenetwork.models.SdfDirection - :ivar protocol: Required. A list of the allowed protocol(s) for this flow. If you want this - flow to be able to use any protocol within the internet protocol suite, use the value ``ip``. - If you only want to allow a selection of protocols, you must use the corresponding IANA - Assigned Internet Protocol Number for each protocol, as described in + :ivar protocol: A list of the allowed protocol(s) for this flow. If you want this flow to be + able to use any protocol within the internet protocol suite, use the value ``ip``. If you only + want to allow a selection of protocols, you must use the corresponding IANA Assigned Internet + Protocol Number for each protocol, as described in https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml. For example, for UDP, you must use 17. If you use the value ``ip`` then you must leave the field ``port`` - unspecified. + unspecified. Required. :vartype protocol: list[str] - :ivar remote_ip_list: Required. The remote IP address(es) to which UEs will connect for this - flow. If you want to allow connections on any IP address, use the value ``any``. Otherwise, you - must provide each of the remote IP addresses to which the packet core instance will connect for - this flow. You must provide each IP address in CIDR notation, including the netmask (for - example, 192.0.2.54/24). + :ivar remote_ip_list: The remote IP address(es) to which UEs will connect for this flow. If you + want to allow connections on any IP address, use the value ``any``. Otherwise, you must provide + each of the remote IP addresses to which the packet core instance will connect for this flow. + You must provide each IP address in CIDR notation, including the netmask (for example, + 192.0.2.54/24). Required. :vartype remote_ip_list: list[str] :ivar ports: The port(s) to which UEs will connect for this flow. You can specify zero or more ports or port ranges. If you specify one or more ports or port ranges then you must specify a @@ -2490,19 +3079,23 @@ class ServiceDataFlowTemplate(msrest.serialization.Model): """ _validation = { - 'template_name': {'required': True, 'max_length': 64, 'min_length': 0, 'pattern': r'^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$'}, - 'direction': {'required': True}, - 'protocol': {'required': True, 'min_items': 1, 'unique': True}, - 'remote_ip_list': {'required': True, 'min_items': 1, 'unique': True}, - 'ports': {'unique': True}, + "template_name": { + "required": True, + "max_length": 64, + "pattern": r"^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$", + }, + "direction": {"required": True}, + "protocol": {"required": True, "min_items": 1, "unique": True}, + "remote_ip_list": {"required": True, "min_items": 1, "unique": True}, + "ports": {"unique": True}, } _attribute_map = { - 'template_name': {'key': 'templateName', 'type': 'str'}, - 'direction': {'key': 'direction', 'type': 'str'}, - 'protocol': {'key': 'protocol', 'type': '[str]'}, - 'remote_ip_list': {'key': 'remoteIpList', 'type': '[str]'}, - 'ports': {'key': 'ports', 'type': '[str]'}, + "template_name": {"key": "templateName", "type": "str"}, + "direction": {"key": "direction", "type": "str"}, + "protocol": {"key": "protocol", "type": "[str]"}, + "remote_ip_list": {"key": "remoteIpList", "type": "[str]"}, + "ports": {"key": "ports", "type": "[str]"}, } def __init__( @@ -2516,26 +3109,26 @@ def __init__( **kwargs ): """ - :keyword template_name: Required. The name of the data flow template. This must be unique - within the parent data flow policy rule. You must not use any of the following reserved strings - - ``default``\ , ``requested`` or ``service``. + :keyword template_name: The name of the data flow template. This must be unique within the + parent data flow policy rule. You must not use any of the following reserved strings - + ``default``\ , ``requested`` or ``service``. Required. :paramtype template_name: str - :keyword direction: Required. The direction of this flow. Known values are: "Uplink", - "Downlink", "Bidirectional". + :keyword direction: The direction of this flow. Required. Known values are: "Uplink", + "Downlink", and "Bidirectional". :paramtype direction: str or ~azure.mgmt.mobilenetwork.models.SdfDirection - :keyword protocol: Required. A list of the allowed protocol(s) for this flow. If you want this - flow to be able to use any protocol within the internet protocol suite, use the value ``ip``. - If you only want to allow a selection of protocols, you must use the corresponding IANA - Assigned Internet Protocol Number for each protocol, as described in + :keyword protocol: A list of the allowed protocol(s) for this flow. If you want this flow to be + able to use any protocol within the internet protocol suite, use the value ``ip``. If you only + want to allow a selection of protocols, you must use the corresponding IANA Assigned Internet + Protocol Number for each protocol, as described in https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml. For example, for UDP, you must use 17. If you use the value ``ip`` then you must leave the field ``port`` - unspecified. + unspecified. Required. :paramtype protocol: list[str] - :keyword remote_ip_list: Required. The remote IP address(es) to which UEs will connect for this - flow. If you want to allow connections on any IP address, use the value ``any``. Otherwise, you - must provide each of the remote IP addresses to which the packet core instance will connect for - this flow. You must provide each IP address in CIDR notation, including the netmask (for - example, 192.0.2.54/24). + :keyword remote_ip_list: The remote IP address(es) to which UEs will connect for this flow. If + you want to allow connections on any IP address, use the value ``any``. Otherwise, you must + provide each of the remote IP addresses to which the packet core instance will connect for this + flow. You must provide each IP address in CIDR notation, including the netmask (for example, + 192.0.2.54/24). Required. :paramtype remote_ip_list: list[str] :keyword ports: The port(s) to which UEs will connect for this flow. You can specify zero or more ports or port ranges. If you specify one or more ports or port ranges then you must @@ -2545,7 +3138,7 @@ def __init__( ]. :paramtype ports: list[str] """ - super(ServiceDataFlowTemplate, self).__init__(**kwargs) + super().__init__(**kwargs) self.template_name = template_name self.direction = direction self.protocol = protocol @@ -2553,7 +3146,7 @@ def __init__( self.ports = ports -class ServiceListResult(msrest.serialization.Model): +class ServiceListResult(_serialization.Model): """Response for services API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -2565,61 +3158,54 @@ class ServiceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Service]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Service]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Service"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Service"]] = None, **kwargs): """ :keyword value: A list of services. :paramtype value: list[~azure.mgmt.mobilenetwork.models.Service] """ - super(ServiceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ServiceResourceId(msrest.serialization.Model): +class ServiceResourceId(_serialization.Model): """Reference to a service resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Service resource ID. + :ivar id: Service resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][eE][rR][vV][iI][cC][eE][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][eE][rR][vV][iI][cC][eE][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Service resource ID. + :keyword id: Service resource ID. Required. :paramtype id: str """ - super(ServiceResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class Sim(ProxyResource): +class Sim(ProxyResource): # pylint: disable=too-many-instance-attributes """SIM resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2638,59 +3224,78 @@ class Sim(ProxyResource): information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData :ivar provisioning_state: The provisioning state of the SIM resource. Known values are: - "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar sim_state: The state of the SIM resource. Known values are: "Disabled", "Enabled", + :ivar sim_state: The state of the SIM resource. Known values are: "Disabled", "Enabled", and "Invalid". :vartype sim_state: str or ~azure.mgmt.mobilenetwork.models.SimState - :ivar international_mobile_subscriber_identity: Required. The international mobile subscriber - identity (IMSI) for the SIM. + :ivar site_provisioning_state: A dictionary of sites to the provisioning state of this SIM on + that site. + :vartype site_provisioning_state: dict[str, str or + ~azure.mgmt.mobilenetwork.models.SiteProvisioningState] + :ivar international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. :vartype international_mobile_subscriber_identity: str :ivar integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the SIM. :vartype integrated_circuit_card_identifier: str - :ivar authentication_key: The Ki value for the SIM. - :vartype authentication_key: str - :ivar operator_key_code: The Opc value for the SIM. - :vartype operator_key_code: str :ivar device_type: An optional free-form text field that can be used to record the device type this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to be grouped and filtered based on this value. :vartype device_type: str - :ivar sim_policy: The SIM policy used by this SIM. + :ivar sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same location + as the SIM. :vartype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId :ivar static_ip_configuration: A list of static IP addresses assigned to this SIM. Each address is assigned at a defined network scope, made up of {attached data network, slice}. :vartype static_ip_configuration: list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :ivar vendor_name: The name of the SIM vendor who provided this SIM, if any. + :vartype vendor_name: str + :ivar vendor_key_fingerprint: The public key fingerprint of the SIM vendor who provided this + SIM, if any. + :vartype vendor_key_fingerprint: str + :ivar authentication_key: The Ki value for the SIM. + :vartype authentication_key: str + :ivar operator_key_code: The Opc value for the SIM. + :vartype operator_key_code: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'sim_state': {'readonly': True}, - 'international_mobile_subscriber_identity': {'required': True, 'pattern': r'^[0-9]{5,15}$'}, - 'integrated_circuit_card_identifier': {'pattern': r'^89[0-9]{17,18}$'}, - 'authentication_key': {'pattern': r'^[0-9a-fA-F]{32}$'}, - 'operator_key_code': {'pattern': r'^[0-9a-fA-F]{32}$'}, - 'static_ip_configuration': {'min_items': 1, 'unique': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "sim_state": {"readonly": True}, + "site_provisioning_state": {"readonly": True}, + "international_mobile_subscriber_identity": {"required": True, "pattern": r"^[0-9]{5,15}$"}, + "integrated_circuit_card_identifier": {"pattern": r"^[0-9]{10,20}$"}, + "static_ip_configuration": {"min_items": 1, "unique": True}, + "vendor_name": {"readonly": True}, + "vendor_key_fingerprint": {"readonly": True}, + "authentication_key": {"pattern": r"^[0-9a-fA-F]{32}$"}, + "operator_key_code": {"pattern": r"^[0-9a-fA-F]{32}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sim_state': {'key': 'properties.simState', 'type': 'str'}, - 'international_mobile_subscriber_identity': {'key': 'properties.internationalMobileSubscriberIdentity', 'type': 'str'}, - 'integrated_circuit_card_identifier': {'key': 'properties.integratedCircuitCardIdentifier', 'type': 'str'}, - 'authentication_key': {'key': 'properties.authenticationKey', 'type': 'str'}, - 'operator_key_code': {'key': 'properties.operatorKeyCode', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'sim_policy': {'key': 'properties.simPolicy', 'type': 'SimPolicyResourceId'}, - 'static_ip_configuration': {'key': 'properties.staticIpConfiguration', 'type': '[SimStaticIpProperties]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sim_state": {"key": "properties.simState", "type": "str"}, + "site_provisioning_state": {"key": "properties.siteProvisioningState", "type": "{str}"}, + "international_mobile_subscriber_identity": { + "key": "properties.internationalMobileSubscriberIdentity", + "type": "str", + }, + "integrated_circuit_card_identifier": {"key": "properties.integratedCircuitCardIdentifier", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "sim_policy": {"key": "properties.simPolicy", "type": "SimPolicyResourceId"}, + "static_ip_configuration": {"key": "properties.staticIpConfiguration", "type": "[SimStaticIpProperties]"}, + "vendor_name": {"key": "properties.vendorName", "type": "str"}, + "vendor_key_fingerprint": {"key": "properties.vendorKeyFingerprint", "type": "str"}, + "authentication_key": {"key": "properties.authenticationKey", "type": "str"}, + "operator_key_code": {"key": "properties.operatorKeyCode", "type": "str"}, } def __init__( @@ -2698,45 +3303,75 @@ def __init__( *, international_mobile_subscriber_identity: str, integrated_circuit_card_identifier: Optional[str] = None, - authentication_key: Optional[str] = None, - operator_key_code: Optional[str] = None, device_type: Optional[str] = None, sim_policy: Optional["_models.SimPolicyResourceId"] = None, static_ip_configuration: Optional[List["_models.SimStaticIpProperties"]] = None, + authentication_key: Optional[str] = None, + operator_key_code: Optional[str] = None, **kwargs ): """ - :keyword international_mobile_subscriber_identity: Required. The international mobile - subscriber identity (IMSI) for the SIM. + :keyword international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. :paramtype international_mobile_subscriber_identity: str :keyword integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the SIM. :paramtype integrated_circuit_card_identifier: str - :keyword authentication_key: The Ki value for the SIM. - :paramtype authentication_key: str - :keyword operator_key_code: The Opc value for the SIM. - :paramtype operator_key_code: str :keyword device_type: An optional free-form text field that can be used to record the device type this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to be grouped and filtered based on this value. :paramtype device_type: str - :keyword sim_policy: The SIM policy used by this SIM. + :keyword sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same + location as the SIM. :paramtype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId :keyword static_ip_configuration: A list of static IP addresses assigned to this SIM. Each address is assigned at a defined network scope, made up of {attached data network, slice}. :paramtype static_ip_configuration: list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :keyword authentication_key: The Ki value for the SIM. + :paramtype authentication_key: str + :keyword operator_key_code: The Opc value for the SIM. + :paramtype operator_key_code: str """ - super(Sim, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.sim_state = None + self.site_provisioning_state = None self.international_mobile_subscriber_identity = international_mobile_subscriber_identity self.integrated_circuit_card_identifier = integrated_circuit_card_identifier - self.authentication_key = authentication_key - self.operator_key_code = operator_key_code self.device_type = device_type self.sim_policy = sim_policy self.static_ip_configuration = static_ip_configuration + self.vendor_name = None + self.vendor_key_fingerprint = None + self.authentication_key = authentication_key + self.operator_key_code = operator_key_code + + +class SimDeleteList(_serialization.Model): + """The SIMs to delete. + + All required parameters must be populated in order to send to Azure. + + :ivar sims: A list of SIM resource names to delete. Required. + :vartype sims: list[str] + """ + + _validation = { + "sims": {"required": True, "min_items": 1}, + } + + _attribute_map = { + "sims": {"key": "sims", "type": "[str]"}, + } + + def __init__(self, *, sims: List[str], **kwargs): + """ + :keyword sims: A list of SIM resource names to delete. Required. + :paramtype sims: list[str] + """ + super().__init__(**kwargs) + self.sims = sims class SimGroup(TrackedResource): @@ -2757,41 +3392,42 @@ class SimGroup(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar identity: The identity used to retrieve the encryption key from Azure key vault. :vartype identity: ~azure.mgmt.mobilenetwork.models.ManagedServiceIdentity :ivar provisioning_state: The provisioning state of the SIM group resource. Known values are: - "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState :ivar encryption_key: A key to encrypt the SIM data that belongs to this SIM group. :vartype encryption_key: ~azure.mgmt.mobilenetwork.models.KeyVaultKey - :ivar mobile_network: Mobile network that this SIM belongs to. + :ivar mobile_network: Mobile network that this SIM group belongs to. The mobile network must be + in the same location as the SIM group. :vartype mobile_network: ~azure.mgmt.mobilenetwork.models.MobileNetworkResourceId """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'KeyVaultKey'}, - 'mobile_network': {'key': 'properties.mobileNetwork', 'type': 'MobileNetworkResourceId'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "KeyVaultKey"}, + "mobile_network": {"key": "properties.mobileNetwork", "type": "MobileNetworkResourceId"}, } def __init__( @@ -2805,25 +3441,26 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity used to retrieve the encryption key from Azure key vault. :paramtype identity: ~azure.mgmt.mobilenetwork.models.ManagedServiceIdentity :keyword encryption_key: A key to encrypt the SIM data that belongs to this SIM group. :paramtype encryption_key: ~azure.mgmt.mobilenetwork.models.KeyVaultKey - :keyword mobile_network: Mobile network that this SIM belongs to. + :keyword mobile_network: Mobile network that this SIM group belongs to. The mobile network must + be in the same location as the SIM group. :paramtype mobile_network: ~azure.mgmt.mobilenetwork.models.MobileNetworkResourceId """ - super(SimGroup, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.identity = identity self.provisioning_state = None self.encryption_key = encryption_key self.mobile_network = mobile_network -class SimGroupListResult(msrest.serialization.Model): +class SimGroupListResult(_serialization.Model): """Response for list SIM groups API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -2835,131 +3472,340 @@ class SimGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SimGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SimGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SimGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SimGroup"]] = None, **kwargs): """ :keyword value: A list of SIM groups in a resource group. :paramtype value: list[~azure.mgmt.mobilenetwork.models.SimGroup] """ - super(SimGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class SimGroupResourceId(msrest.serialization.Model): +class SimGroupResourceId(_serialization.Model): """Reference to a SIM group resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. SIM group resource ID. + :ivar id: SIM group resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][iI][mM][gG][rR][oO][uU][pP][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[sS][iI][mM][gG][rR][oO][uU][pP][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. SIM group resource ID. + :keyword id: SIM group resource ID. Required. :paramtype id: str """ - super(SimGroupResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SimIdListResult(msrest.serialization.Model): - """Response for list SIM IDs API service call. +class SimListResult(_serialization.Model): + """Response for list SIMs API service call. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: A list of SIM IDs. - :vartype value: list[~azure.mgmt.mobilenetwork.models.SubResource] + :ivar value: A list of SIMs in a resource group. + :vartype value: list[~azure.mgmt.mobilenetwork.models.Sim] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Sim]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Sim"]] = None, **kwargs): + """ + :keyword value: A list of SIMs in a resource group. + :paramtype value: list[~azure.mgmt.mobilenetwork.models.Sim] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class SimNameAndEncryptedProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """SIM name and encrypted properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the SIM. Required. + :vartype name: str + :ivar provisioning_state: The provisioning state of the SIM resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState + :ivar sim_state: The state of the SIM resource. Known values are: "Disabled", "Enabled", and + "Invalid". + :vartype sim_state: str or ~azure.mgmt.mobilenetwork.models.SimState + :ivar site_provisioning_state: A dictionary of sites to the provisioning state of this SIM on + that site. + :vartype site_provisioning_state: dict[str, str or + ~azure.mgmt.mobilenetwork.models.SiteProvisioningState] + :ivar international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :vartype international_mobile_subscriber_identity: str + :ivar integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the SIM. + :vartype integrated_circuit_card_identifier: str + :ivar device_type: An optional free-form text field that can be used to record the device type + this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to be + grouped and filtered based on this value. + :vartype device_type: str + :ivar sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same location + as the SIM. + :vartype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :ivar static_ip_configuration: A list of static IP addresses assigned to this SIM. Each address + is assigned at a defined network scope, made up of {attached data network, slice}. + :vartype static_ip_configuration: list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :ivar vendor_name: The name of the SIM vendor who provided this SIM, if any. + :vartype vendor_name: str + :ivar vendor_key_fingerprint: The public key fingerprint of the SIM vendor who provided this + SIM, if any. + :vartype vendor_key_fingerprint: str + :ivar encrypted_credentials: The encrypted SIM credentials. + :vartype encrypted_credentials: str + """ + + _validation = { + "name": {"required": True}, + "provisioning_state": {"readonly": True}, + "sim_state": {"readonly": True}, + "site_provisioning_state": {"readonly": True}, + "international_mobile_subscriber_identity": {"required": True, "pattern": r"^[0-9]{5,15}$"}, + "integrated_circuit_card_identifier": {"pattern": r"^[0-9]{10,20}$"}, + "static_ip_configuration": {"min_items": 1, "unique": True}, + "vendor_name": {"readonly": True}, + "vendor_key_fingerprint": {"readonly": True}, + "encrypted_credentials": {"pattern": r"^[0-9a-fA-F]+$"}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SubResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sim_state": {"key": "properties.simState", "type": "str"}, + "site_provisioning_state": {"key": "properties.siteProvisioningState", "type": "{str}"}, + "international_mobile_subscriber_identity": { + "key": "properties.internationalMobileSubscriberIdentity", + "type": "str", + }, + "integrated_circuit_card_identifier": {"key": "properties.integratedCircuitCardIdentifier", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "sim_policy": {"key": "properties.simPolicy", "type": "SimPolicyResourceId"}, + "static_ip_configuration": {"key": "properties.staticIpConfiguration", "type": "[SimStaticIpProperties]"}, + "vendor_name": {"key": "properties.vendorName", "type": "str"}, + "vendor_key_fingerprint": {"key": "properties.vendorKeyFingerprint", "type": "str"}, + "encrypted_credentials": {"key": "properties.encryptedCredentials", "type": "str"}, } def __init__( self, *, - value: Optional[List["_models.SubResource"]] = None, + name: str, + international_mobile_subscriber_identity: str, + integrated_circuit_card_identifier: Optional[str] = None, + device_type: Optional[str] = None, + sim_policy: Optional["_models.SimPolicyResourceId"] = None, + static_ip_configuration: Optional[List["_models.SimStaticIpProperties"]] = None, + encrypted_credentials: Optional[str] = None, **kwargs ): """ - :keyword value: A list of SIM IDs. - :paramtype value: list[~azure.mgmt.mobilenetwork.models.SubResource] + :keyword name: The name of the SIM. Required. + :paramtype name: str + :keyword international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :paramtype international_mobile_subscriber_identity: str + :keyword integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the + SIM. + :paramtype integrated_circuit_card_identifier: str + :keyword device_type: An optional free-form text field that can be used to record the device + type this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to + be grouped and filtered based on this value. + :paramtype device_type: str + :keyword sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same + location as the SIM. + :paramtype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :keyword static_ip_configuration: A list of static IP addresses assigned to this SIM. Each + address is assigned at a defined network scope, made up of {attached data network, slice}. + :paramtype static_ip_configuration: + list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :keyword encrypted_credentials: The encrypted SIM credentials. + :paramtype encrypted_credentials: str """ - super(SimIdListResult, self).__init__(**kwargs) - self.value = value - self.next_link = None + super().__init__(**kwargs) + self.name = name + self.provisioning_state = None + self.sim_state = None + self.site_provisioning_state = None + self.international_mobile_subscriber_identity = international_mobile_subscriber_identity + self.integrated_circuit_card_identifier = integrated_circuit_card_identifier + self.device_type = device_type + self.sim_policy = sim_policy + self.static_ip_configuration = static_ip_configuration + self.vendor_name = None + self.vendor_key_fingerprint = None + self.encrypted_credentials = encrypted_credentials -class SimListResult(msrest.serialization.Model): - """Response for list SIMs API service call. +class SimNameAndProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """SIM name and properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: A list of SIMs in a resource group. - :vartype value: list[~azure.mgmt.mobilenetwork.models.Sim] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the SIM. Required. + :vartype name: str + :ivar provisioning_state: The provisioning state of the SIM resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState + :ivar sim_state: The state of the SIM resource. Known values are: "Disabled", "Enabled", and + "Invalid". + :vartype sim_state: str or ~azure.mgmt.mobilenetwork.models.SimState + :ivar site_provisioning_state: A dictionary of sites to the provisioning state of this SIM on + that site. + :vartype site_provisioning_state: dict[str, str or + ~azure.mgmt.mobilenetwork.models.SiteProvisioningState] + :ivar international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :vartype international_mobile_subscriber_identity: str + :ivar integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the SIM. + :vartype integrated_circuit_card_identifier: str + :ivar device_type: An optional free-form text field that can be used to record the device type + this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to be + grouped and filtered based on this value. + :vartype device_type: str + :ivar sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same location + as the SIM. + :vartype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :ivar static_ip_configuration: A list of static IP addresses assigned to this SIM. Each address + is assigned at a defined network scope, made up of {attached data network, slice}. + :vartype static_ip_configuration: list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :ivar vendor_name: The name of the SIM vendor who provided this SIM, if any. + :vartype vendor_name: str + :ivar vendor_key_fingerprint: The public key fingerprint of the SIM vendor who provided this + SIM, if any. + :vartype vendor_key_fingerprint: str + :ivar authentication_key: The Ki value for the SIM. + :vartype authentication_key: str + :ivar operator_key_code: The Opc value for the SIM. + :vartype operator_key_code: str """ _validation = { - 'next_link': {'readonly': True}, + "name": {"required": True}, + "provisioning_state": {"readonly": True}, + "sim_state": {"readonly": True}, + "site_provisioning_state": {"readonly": True}, + "international_mobile_subscriber_identity": {"required": True, "pattern": r"^[0-9]{5,15}$"}, + "integrated_circuit_card_identifier": {"pattern": r"^[0-9]{10,20}$"}, + "static_ip_configuration": {"min_items": 1, "unique": True}, + "vendor_name": {"readonly": True}, + "vendor_key_fingerprint": {"readonly": True}, + "authentication_key": {"pattern": r"^[0-9a-fA-F]{32}$"}, + "operator_key_code": {"pattern": r"^[0-9a-fA-F]{32}$"}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sim]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sim_state": {"key": "properties.simState", "type": "str"}, + "site_provisioning_state": {"key": "properties.siteProvisioningState", "type": "{str}"}, + "international_mobile_subscriber_identity": { + "key": "properties.internationalMobileSubscriberIdentity", + "type": "str", + }, + "integrated_circuit_card_identifier": {"key": "properties.integratedCircuitCardIdentifier", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "sim_policy": {"key": "properties.simPolicy", "type": "SimPolicyResourceId"}, + "static_ip_configuration": {"key": "properties.staticIpConfiguration", "type": "[SimStaticIpProperties]"}, + "vendor_name": {"key": "properties.vendorName", "type": "str"}, + "vendor_key_fingerprint": {"key": "properties.vendorKeyFingerprint", "type": "str"}, + "authentication_key": {"key": "properties.authenticationKey", "type": "str"}, + "operator_key_code": {"key": "properties.operatorKeyCode", "type": "str"}, } def __init__( self, *, - value: Optional[List["_models.Sim"]] = None, + name: str, + international_mobile_subscriber_identity: str, + integrated_circuit_card_identifier: Optional[str] = None, + device_type: Optional[str] = None, + sim_policy: Optional["_models.SimPolicyResourceId"] = None, + static_ip_configuration: Optional[List["_models.SimStaticIpProperties"]] = None, + authentication_key: Optional[str] = None, + operator_key_code: Optional[str] = None, **kwargs ): """ - :keyword value: A list of SIMs in a resource group. - :paramtype value: list[~azure.mgmt.mobilenetwork.models.Sim] + :keyword name: The name of the SIM. Required. + :paramtype name: str + :keyword international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :paramtype international_mobile_subscriber_identity: str + :keyword integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the + SIM. + :paramtype integrated_circuit_card_identifier: str + :keyword device_type: An optional free-form text field that can be used to record the device + type this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to + be grouped and filtered based on this value. + :paramtype device_type: str + :keyword sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same + location as the SIM. + :paramtype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :keyword static_ip_configuration: A list of static IP addresses assigned to this SIM. Each + address is assigned at a defined network scope, made up of {attached data network, slice}. + :paramtype static_ip_configuration: + list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :keyword authentication_key: The Ki value for the SIM. + :paramtype authentication_key: str + :keyword operator_key_code: The Opc value for the SIM. + :paramtype operator_key_code: str """ - super(SimListResult, self).__init__(**kwargs) - self.value = value - self.next_link = None + super().__init__(**kwargs) + self.name = name + self.provisioning_state = None + self.sim_state = None + self.site_provisioning_state = None + self.international_mobile_subscriber_identity = international_mobile_subscriber_identity + self.integrated_circuit_card_identifier = integrated_circuit_card_identifier + self.device_type = device_type + self.sim_policy = sim_policy + self.static_ip_configuration = static_ip_configuration + self.vendor_name = None + self.vendor_key_fingerprint = None + self.authentication_key = authentication_key + self.operator_key_code = operator_key_code -class SimPolicy(TrackedResource): +class SimPolicy(TrackedResource): # pylint: disable=too-many-instance-attributes """SIM policy resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2977,19 +3823,23 @@ class SimPolicy(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the SIM policy resource. Known values are: - "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar ue_ambr: Required. Aggregate maximum bit rate across all non-GBR QoS flows of all PDU - sessions of a given UE. See 3GPP TS23.501 section 5.7.2.6 for a full description of the - UE-AMBR. + :ivar site_provisioning_state: A dictionary of sites to the provisioning state of this SIM + policy on that site. + :vartype site_provisioning_state: dict[str, str or + ~azure.mgmt.mobilenetwork.models.SiteProvisioningState] + :ivar ue_ambr: Aggregate maximum bit rate across all non-GBR QoS flows of all PDU sessions of a + given UE. See 3GPP TS23.501 section 5.7.2.6 for a full description of the UE-AMBR. Required. :vartype ue_ambr: ~azure.mgmt.mobilenetwork.models.Ambr - :ivar default_slice: Required. The default slice to use if the UE does not explicitly specify - it. This slice must exist in the ``sliceConfigurations`` map. + :ivar default_slice: The default slice to use if the UE does not explicitly specify it. This + slice must exist in the ``sliceConfigurations`` map. The slice must be in the same location as + the SIM policy. Required. :vartype default_slice: ~azure.mgmt.mobilenetwork.models.SliceResourceId :ivar rfsp_index: RAT/Frequency Selection Priority Index, defined in 3GPP TS 36.413. This is an optional setting and by default is unspecified. @@ -2997,38 +3847,40 @@ class SimPolicy(TrackedResource): :ivar registration_timer: Interval for the UE periodic registration update procedure, in seconds. :vartype registration_timer: int - :ivar slice_configurations: Required. The allowed slices and the settings to use for them. The - list must not contain duplicate items and must contain at least one item. + :ivar slice_configurations: The allowed slices and the settings to use for them. The list must + not contain duplicate items and must contain at least one item. Required. :vartype slice_configurations: list[~azure.mgmt.mobilenetwork.models.SliceConfiguration] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'ue_ambr': {'required': True}, - 'default_slice': {'required': True}, - 'rfsp_index': {'maximum': 256, 'minimum': 1}, - 'registration_timer': {'minimum': 30}, - 'slice_configurations': {'required': True, 'min_items': 1, 'unique': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "site_provisioning_state": {"readonly": True}, + "ue_ambr": {"required": True}, + "default_slice": {"required": True}, + "rfsp_index": {"maximum": 256, "minimum": 1}, + "registration_timer": {"minimum": 30}, + "slice_configurations": {"required": True, "min_items": 1, "unique": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'ue_ambr': {'key': 'properties.ueAmbr', 'type': 'Ambr'}, - 'default_slice': {'key': 'properties.defaultSlice', 'type': 'SliceResourceId'}, - 'rfsp_index': {'key': 'properties.rfspIndex', 'type': 'int'}, - 'registration_timer': {'key': 'properties.registrationTimer', 'type': 'int'}, - 'slice_configurations': {'key': 'properties.sliceConfigurations', 'type': '[SliceConfiguration]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "site_provisioning_state": {"key": "properties.siteProvisioningState", "type": "{str}"}, + "ue_ambr": {"key": "properties.ueAmbr", "type": "Ambr"}, + "default_slice": {"key": "properties.defaultSlice", "type": "SliceResourceId"}, + "rfsp_index": {"key": "properties.rfspIndex", "type": "int"}, + "registration_timer": {"key": "properties.registrationTimer", "type": "int"}, + "slice_configurations": {"key": "properties.sliceConfigurations", "type": "[SliceConfiguration]"}, } def __init__( @@ -3040,20 +3892,21 @@ def __init__( slice_configurations: List["_models.SliceConfiguration"], tags: Optional[Dict[str, str]] = None, rfsp_index: Optional[int] = None, - registration_timer: Optional[int] = 3240, + registration_timer: int = 3240, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword ue_ambr: Required. Aggregate maximum bit rate across all non-GBR QoS flows of all PDU - sessions of a given UE. See 3GPP TS23.501 section 5.7.2.6 for a full description of the - UE-AMBR. + :keyword ue_ambr: Aggregate maximum bit rate across all non-GBR QoS flows of all PDU sessions + of a given UE. See 3GPP TS23.501 section 5.7.2.6 for a full description of the UE-AMBR. + Required. :paramtype ue_ambr: ~azure.mgmt.mobilenetwork.models.Ambr - :keyword default_slice: Required. The default slice to use if the UE does not explicitly - specify it. This slice must exist in the ``sliceConfigurations`` map. + :keyword default_slice: The default slice to use if the UE does not explicitly specify it. This + slice must exist in the ``sliceConfigurations`` map. The slice must be in the same location as + the SIM policy. Required. :paramtype default_slice: ~azure.mgmt.mobilenetwork.models.SliceResourceId :keyword rfsp_index: RAT/Frequency Selection Priority Index, defined in 3GPP TS 36.413. This is an optional setting and by default is unspecified. @@ -3061,12 +3914,13 @@ def __init__( :keyword registration_timer: Interval for the UE periodic registration update procedure, in seconds. :paramtype registration_timer: int - :keyword slice_configurations: Required. The allowed slices and the settings to use for them. - The list must not contain duplicate items and must contain at least one item. + :keyword slice_configurations: The allowed slices and the settings to use for them. The list + must not contain duplicate items and must contain at least one item. Required. :paramtype slice_configurations: list[~azure.mgmt.mobilenetwork.models.SliceConfiguration] """ - super(SimPolicy, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None + self.site_provisioning_state = None self.ue_ambr = ue_ambr self.default_slice = default_slice self.rfsp_index = rfsp_index @@ -3074,7 +3928,7 @@ def __init__( self.slice_configurations = slice_configurations -class SimPolicyListResult(msrest.serialization.Model): +class SimPolicyListResult(_serialization.Model): """Response for SIM policies API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -3086,78 +3940,190 @@ class SimPolicyListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SimPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SimPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SimPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SimPolicy"]] = None, **kwargs): """ :keyword value: A list of SIM policies. :paramtype value: list[~azure.mgmt.mobilenetwork.models.SimPolicy] """ - super(SimPolicyListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class SimPolicyResourceId(msrest.serialization.Model): +class SimPolicyResourceId(_serialization.Model): """Reference to a SIM policy resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. SIM policy resource ID. + :ivar id: SIM policy resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][iI][mM][pP][oO][lL][iI][cC][iI][eE][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][iI][mM][pP][oO][lL][iI][cC][iI][eE][sS]/[^/?#]+$", + }, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: SIM policy resource ID. Required. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class SimPropertiesFormat(CommonSimPropertiesFormat): # pylint: disable=too-many-instance-attributes + """SIM properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar provisioning_state: The provisioning state of the SIM resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState + :ivar sim_state: The state of the SIM resource. Known values are: "Disabled", "Enabled", and + "Invalid". + :vartype sim_state: str or ~azure.mgmt.mobilenetwork.models.SimState + :ivar site_provisioning_state: A dictionary of sites to the provisioning state of this SIM on + that site. + :vartype site_provisioning_state: dict[str, str or + ~azure.mgmt.mobilenetwork.models.SiteProvisioningState] + :ivar international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :vartype international_mobile_subscriber_identity: str + :ivar integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the SIM. + :vartype integrated_circuit_card_identifier: str + :ivar device_type: An optional free-form text field that can be used to record the device type + this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to be + grouped and filtered based on this value. + :vartype device_type: str + :ivar sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same location + as the SIM. + :vartype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :ivar static_ip_configuration: A list of static IP addresses assigned to this SIM. Each address + is assigned at a defined network scope, made up of {attached data network, slice}. + :vartype static_ip_configuration: list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :ivar vendor_name: The name of the SIM vendor who provided this SIM, if any. + :vartype vendor_name: str + :ivar vendor_key_fingerprint: The public key fingerprint of the SIM vendor who provided this + SIM, if any. + :vartype vendor_key_fingerprint: str + :ivar authentication_key: The Ki value for the SIM. + :vartype authentication_key: str + :ivar operator_key_code: The Opc value for the SIM. + :vartype operator_key_code: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "sim_state": {"readonly": True}, + "site_provisioning_state": {"readonly": True}, + "international_mobile_subscriber_identity": {"required": True, "pattern": r"^[0-9]{5,15}$"}, + "integrated_circuit_card_identifier": {"pattern": r"^[0-9]{10,20}$"}, + "static_ip_configuration": {"min_items": 1, "unique": True}, + "vendor_name": {"readonly": True}, + "vendor_key_fingerprint": {"readonly": True}, + "authentication_key": {"pattern": r"^[0-9a-fA-F]{32}$"}, + "operator_key_code": {"pattern": r"^[0-9a-fA-F]{32}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "sim_state": {"key": "simState", "type": "str"}, + "site_provisioning_state": {"key": "siteProvisioningState", "type": "{str}"}, + "international_mobile_subscriber_identity": {"key": "internationalMobileSubscriberIdentity", "type": "str"}, + "integrated_circuit_card_identifier": {"key": "integratedCircuitCardIdentifier", "type": "str"}, + "device_type": {"key": "deviceType", "type": "str"}, + "sim_policy": {"key": "simPolicy", "type": "SimPolicyResourceId"}, + "static_ip_configuration": {"key": "staticIpConfiguration", "type": "[SimStaticIpProperties]"}, + "vendor_name": {"key": "vendorName", "type": "str"}, + "vendor_key_fingerprint": {"key": "vendorKeyFingerprint", "type": "str"}, + "authentication_key": {"key": "authenticationKey", "type": "str"}, + "operator_key_code": {"key": "operatorKeyCode", "type": "str"}, } def __init__( self, *, - id: str, + international_mobile_subscriber_identity: str, + integrated_circuit_card_identifier: Optional[str] = None, + device_type: Optional[str] = None, + sim_policy: Optional["_models.SimPolicyResourceId"] = None, + static_ip_configuration: Optional[List["_models.SimStaticIpProperties"]] = None, + authentication_key: Optional[str] = None, + operator_key_code: Optional[str] = None, **kwargs ): """ - :keyword id: Required. SIM policy resource ID. - :paramtype id: str + :keyword international_mobile_subscriber_identity: The international mobile subscriber identity + (IMSI) for the SIM. Required. + :paramtype international_mobile_subscriber_identity: str + :keyword integrated_circuit_card_identifier: The integrated circuit card ID (ICCID) for the + SIM. + :paramtype integrated_circuit_card_identifier: str + :keyword device_type: An optional free-form text field that can be used to record the device + type this SIM is associated with, for example 'Video camera'. The Azure portal allows SIMs to + be grouped and filtered based on this value. + :paramtype device_type: str + :keyword sim_policy: The SIM policy used by this SIM. The SIM policy must be in the same + location as the SIM. + :paramtype sim_policy: ~azure.mgmt.mobilenetwork.models.SimPolicyResourceId + :keyword static_ip_configuration: A list of static IP addresses assigned to this SIM. Each + address is assigned at a defined network scope, made up of {attached data network, slice}. + :paramtype static_ip_configuration: + list[~azure.mgmt.mobilenetwork.models.SimStaticIpProperties] + :keyword authentication_key: The Ki value for the SIM. + :paramtype authentication_key: str + :keyword operator_key_code: The Opc value for the SIM. + :paramtype operator_key_code: str """ - super(SimPolicyResourceId, self).__init__(**kwargs) - self.id = id + super().__init__( + international_mobile_subscriber_identity=international_mobile_subscriber_identity, + integrated_circuit_card_identifier=integrated_circuit_card_identifier, + device_type=device_type, + sim_policy=sim_policy, + static_ip_configuration=static_ip_configuration, + **kwargs + ) + self.authentication_key = authentication_key + self.operator_key_code = operator_key_code -class SimStaticIpProperties(msrest.serialization.Model): +class SimStaticIpProperties(_serialization.Model): """Static IP configuration for a SIM, scoped to a particular attached data network and slice. :ivar attached_data_network: The attached data network on which the static IP address will be used. The combination of attached data network and slice defines the network scope of the IP - address. + address. The attached data network must be in the same location as the SIM. :vartype attached_data_network: ~azure.mgmt.mobilenetwork.models.AttachedDataNetworkResourceId :ivar slice: The network slice on which the static IP address will be used. The combination of - attached data network and slice defines the network scope of the IP address. + attached data network and slice defines the network scope of the IP address. The slice must be + in the same location as the SIM. :vartype slice: ~azure.mgmt.mobilenetwork.models.SliceResourceId :ivar static_ip: The static IP configuration for the SIM to use at the defined network scope. :vartype static_ip: ~azure.mgmt.mobilenetwork.models.SimStaticIpPropertiesStaticIp """ _attribute_map = { - 'attached_data_network': {'key': 'attachedDataNetwork', 'type': 'AttachedDataNetworkResourceId'}, - 'slice': {'key': 'slice', 'type': 'SliceResourceId'}, - 'static_ip': {'key': 'staticIp', 'type': 'SimStaticIpPropertiesStaticIp'}, + "attached_data_network": {"key": "attachedDataNetwork", "type": "AttachedDataNetworkResourceId"}, + "slice": {"key": "slice", "type": "SliceResourceId"}, + "static_ip": {"key": "staticIp", "type": "SimStaticIpPropertiesStaticIp"}, } def __init__( @@ -3171,23 +4137,24 @@ def __init__( """ :keyword attached_data_network: The attached data network on which the static IP address will be used. The combination of attached data network and slice defines the network scope of the IP - address. + address. The attached data network must be in the same location as the SIM. :paramtype attached_data_network: ~azure.mgmt.mobilenetwork.models.AttachedDataNetworkResourceId :keyword slice: The network slice on which the static IP address will be used. The combination - of attached data network and slice defines the network scope of the IP address. + of attached data network and slice defines the network scope of the IP address. The slice must + be in the same location as the SIM. :paramtype slice: ~azure.mgmt.mobilenetwork.models.SliceResourceId :keyword static_ip: The static IP configuration for the SIM to use at the defined network scope. :paramtype static_ip: ~azure.mgmt.mobilenetwork.models.SimStaticIpPropertiesStaticIp """ - super(SimStaticIpProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.attached_data_network = attached_data_network self.slice = slice self.static_ip = static_ip -class SimStaticIpPropertiesStaticIp(msrest.serialization.Model): +class SimStaticIpPropertiesStaticIp(_serialization.Model): """The static IP configuration for the SIM to use at the defined network scope. :ivar ipv4_address: The IPv4 address assigned to the SIM at this network scope. This address @@ -3196,30 +4163,53 @@ class SimStaticIpPropertiesStaticIp(msrest.serialization.Model): """ _validation = { - 'ipv4_address': {'pattern': r'^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$'}, + "ipv4_address": { + "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$" + }, } _attribute_map = { - 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, + "ipv4_address": {"key": "ipv4Address", "type": "str"}, } - def __init__( - self, - *, - ipv4_address: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ipv4_address: Optional[str] = None, **kwargs): """ :keyword ipv4_address: The IPv4 address assigned to the SIM at this network scope. This address must be in the userEquipmentStaticAddressPoolPrefix defined in the attached data network. :paramtype ipv4_address: str """ - super(SimStaticIpPropertiesStaticIp, self).__init__(**kwargs) + super().__init__(**kwargs) self.ipv4_address = ipv4_address +class SimUploadList(_serialization.Model): + """The SIMs to upload. + + All required parameters must be populated in order to send to Azure. + + :ivar sims: A list of SIMs to upload. Required. + :vartype sims: list[~azure.mgmt.mobilenetwork.models.SimNameAndProperties] + """ + + _validation = { + "sims": {"required": True, "min_items": 1}, + } + + _attribute_map = { + "sims": {"key": "sims", "type": "[SimNameAndProperties]"}, + } + + def __init__(self, *, sims: List["_models.SimNameAndProperties"], **kwargs): + """ + :keyword sims: A list of SIMs to upload. Required. + :paramtype sims: list[~azure.mgmt.mobilenetwork.models.SimNameAndProperties] + """ + super().__init__(**kwargs) + self.sims = sims + + class Site(TrackedResource): - """Site resource. + """Site resource. Must be created in the same location as its parent mobile network. Variables are only populated by the server, and will be ignored when sending a request. @@ -3236,61 +4226,52 @@ class Site(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the site resource. Known values are: - "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar network_functions: An array of IDs of the network functions deployed on the site, - maintained by the user. + :ivar network_functions: An array of IDs of the network functions deployed in the site. + Deleting the site will delete any network functions that are deployed in the site. :vartype network_functions: list[~azure.mgmt.mobilenetwork.models.SubResource] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "network_functions": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'network_functions': {'key': 'properties.networkFunctions', 'type': '[SubResource]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "network_functions": {"key": "properties.networkFunctions", "type": "[SubResource]"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - network_functions: Optional[List["_models.SubResource"]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword network_functions: An array of IDs of the network functions deployed on the site, - maintained by the user. - :paramtype network_functions: list[~azure.mgmt.mobilenetwork.models.SubResource] """ - super(Site, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None - self.network_functions = network_functions + self.network_functions = None -class SiteListResult(msrest.serialization.Model): +class SiteListResult(_serialization.Model): """Response for sites API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -3302,31 +4283,55 @@ class SiteListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Site]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Site]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Site"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Site"]] = None, **kwargs): """ :keyword value: A list of sites in a mobile network. :paramtype value: list[~azure.mgmt.mobilenetwork.models.Site] """ - super(SiteListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None +class SiteResourceId(_serialization.Model): + """Reference to a site resource. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Site resource ID. Required. + :vartype id: str + """ + + _validation = { + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][iI][tT][eE][sS]/[^/?#]+$", + }, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: Site resource ID. Required. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + class Slice(TrackedResource): - """Network slice resource. + """Network slice resource. Must be created in the same location as its parent mobile network. Variables are only populated by the server, and will be ignored when sending a request. @@ -3343,40 +4348,40 @@ class Slice(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.mobilenetwork.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The provisioning state of the network slice resource. Known values - are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", and "Deleted". :vartype provisioning_state: str or ~azure.mgmt.mobilenetwork.models.ProvisioningState - :ivar snssai: Required. Single-network slice selection assistance information (S-NSSAI). Unique - at the scope of a mobile network. + :ivar snssai: Single-network slice selection assistance information (S-NSSAI). Unique at the + scope of a mobile network. Required. :vartype snssai: ~azure.mgmt.mobilenetwork.models.Snssai :ivar description: An optional description for this network slice. :vartype description: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'snssai': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "snssai": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'snssai': {'key': 'properties.snssai', 'type': 'Snssai'}, - 'description': {'key': 'properties.description', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "snssai": {"key": "properties.snssai", "type": "Snssai"}, + "description": {"key": "properties.description", "type": "str"}, } def __init__( @@ -3389,49 +4394,50 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword snssai: Required. Single-network slice selection assistance information (S-NSSAI). - Unique at the scope of a mobile network. + :keyword snssai: Single-network slice selection assistance information (S-NSSAI). Unique at the + scope of a mobile network. Required. :paramtype snssai: ~azure.mgmt.mobilenetwork.models.Snssai :keyword description: An optional description for this network slice. :paramtype description: str """ - super(Slice, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = None self.snssai = snssai self.description = description -class SliceConfiguration(msrest.serialization.Model): +class SliceConfiguration(_serialization.Model): """Per-slice settings. All required parameters must be populated in order to send to Azure. - :ivar slice: Required. A reference to the slice that these settings apply to. + :ivar slice: A reference to the slice that these settings apply to. The slice must be in the + same location as the SIM policy. Required. :vartype slice: ~azure.mgmt.mobilenetwork.models.SliceResourceId - :ivar default_data_network: Required. The default data network to use if the UE does not - explicitly specify it. Configuration for this object must exist in the - ``dataNetworkConfigurations`` map. + :ivar default_data_network: The default data network to use if the UE does not explicitly + specify it. Configuration for this object must exist in the ``dataNetworkConfigurations`` map. + The data network must be in the same location as the SIM policy. Required. :vartype default_data_network: ~azure.mgmt.mobilenetwork.models.DataNetworkResourceId - :ivar data_network_configurations: Required. The allowed data networks and the settings to use - for them. The list must not contain duplicate items and must contain at least one item. + :ivar data_network_configurations: The allowed data networks and the settings to use for them. + The list must not contain duplicate items and must contain at least one item. Required. :vartype data_network_configurations: list[~azure.mgmt.mobilenetwork.models.DataNetworkConfiguration] """ _validation = { - 'slice': {'required': True}, - 'default_data_network': {'required': True}, - 'data_network_configurations': {'required': True, 'min_items': 1, 'unique': True}, + "slice": {"required": True}, + "default_data_network": {"required": True}, + "data_network_configurations": {"required": True, "min_items": 1, "unique": True}, } _attribute_map = { - 'slice': {'key': 'slice', 'type': 'SliceResourceId'}, - 'default_data_network': {'key': 'defaultDataNetwork', 'type': 'DataNetworkResourceId'}, - 'data_network_configurations': {'key': 'dataNetworkConfigurations', 'type': '[DataNetworkConfiguration]'}, + "slice": {"key": "slice", "type": "SliceResourceId"}, + "default_data_network": {"key": "defaultDataNetwork", "type": "DataNetworkResourceId"}, + "data_network_configurations": {"key": "dataNetworkConfigurations", "type": "[DataNetworkConfiguration]"}, } def __init__( @@ -3443,24 +4449,25 @@ def __init__( **kwargs ): """ - :keyword slice: Required. A reference to the slice that these settings apply to. + :keyword slice: A reference to the slice that these settings apply to. The slice must be in the + same location as the SIM policy. Required. :paramtype slice: ~azure.mgmt.mobilenetwork.models.SliceResourceId - :keyword default_data_network: Required. The default data network to use if the UE does not - explicitly specify it. Configuration for this object must exist in the - ``dataNetworkConfigurations`` map. + :keyword default_data_network: The default data network to use if the UE does not explicitly + specify it. Configuration for this object must exist in the ``dataNetworkConfigurations`` map. + The data network must be in the same location as the SIM policy. Required. :paramtype default_data_network: ~azure.mgmt.mobilenetwork.models.DataNetworkResourceId - :keyword data_network_configurations: Required. The allowed data networks and the settings to - use for them. The list must not contain duplicate items and must contain at least one item. + :keyword data_network_configurations: The allowed data networks and the settings to use for + them. The list must not contain duplicate items and must contain at least one item. Required. :paramtype data_network_configurations: list[~azure.mgmt.mobilenetwork.models.DataNetworkConfiguration] """ - super(SliceConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.slice = slice self.default_data_network = default_data_network self.data_network_configurations = data_network_configurations -class SliceListResult(msrest.serialization.Model): +class SliceListResult(_serialization.Model): """Response for network slice API service call. Variables are only populated by the server, and will be ignored when sending a request. @@ -3472,156 +4479,138 @@ class SliceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Slice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Slice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Slice"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Slice"]] = None, **kwargs): """ :keyword value: A list of network slices in a mobile network. :paramtype value: list[~azure.mgmt.mobilenetwork.models.Slice] """ - super(SliceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class SliceResourceId(msrest.serialization.Model): +class SliceResourceId(_serialization.Model): """Reference to a slice resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Slice resource ID. + :ivar id: Slice resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True, 'pattern': r'^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][lL][iI][cC][eE][sS]/[^/?#]+$'}, + "id": { + "required": True, + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK]/[mM][oO][bB][iI][lL][eE][nN][eE][tT][wW][oO][rR][kK][sS]/[^/?#]+/[sS][lL][iI][cC][eE][sS]/[^/?#]+$", + }, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Slice resource ID. + :keyword id: Slice resource ID. Required. :paramtype id: str """ - super(SliceResourceId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class Snssai(msrest.serialization.Model): +class Snssai(_serialization.Model): """Single-network slice selection assistance information (S-NSSAI). All required parameters must be populated in order to send to Azure. - :ivar sst: Required. Slice/service type (SST). + :ivar sst: Slice/service type (SST). Required. :vartype sst: int :ivar sd: Slice differentiator (SD). :vartype sd: str """ _validation = { - 'sst': {'required': True, 'maximum': 255, 'minimum': 0}, - 'sd': {'pattern': r'^[A-Fa-f0-9]{6}$'}, + "sst": {"required": True, "maximum": 255, "minimum": 0}, + "sd": {"pattern": r"^[A-Fa-f0-9]{6}$"}, } _attribute_map = { - 'sst': {'key': 'sst', 'type': 'int'}, - 'sd': {'key': 'sd', 'type': 'str'}, + "sst": {"key": "sst", "type": "int"}, + "sd": {"key": "sd", "type": "str"}, } - def __init__( - self, - *, - sst: int, - sd: Optional[str] = None, - **kwargs - ): + def __init__(self, *, sst: int, sd: Optional[str] = None, **kwargs): """ - :keyword sst: Required. Slice/service type (SST). + :keyword sst: Slice/service type (SST). Required. :paramtype sst: int :keyword sd: Slice differentiator (SD). :paramtype sd: str """ - super(Snssai, self).__init__(**kwargs) + super().__init__(**kwargs) self.sst = sst self.sd = sd -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Reference to another sub resource. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID. + :ivar id: Resource ID. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID. + :keyword id: Resource ID. Required. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.mobilenetwork.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.mobilenetwork.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( @@ -3639,19 +4628,19 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.mobilenetwork.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.mobilenetwork.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -3660,32 +4649,27 @@ def __init__( self.last_modified_at = last_modified_at -class TagsObject(msrest.serialization.Model): +class TagsObject(_serialization.Model): """Tags object for patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """User assigned identity properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -3697,21 +4681,17 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_patch.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_patch.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py index 8b9269226627..3173a921e4c3 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py @@ -9,34 +9,39 @@ from ._attached_data_networks_operations import AttachedDataNetworksOperations from ._data_networks_operations import DataNetworksOperations from ._mobile_networks_operations import MobileNetworksOperations -from ._sites_operations import SitesOperations -from ._sim_groups_operations import SimGroupsOperations -from ._sims_operations import SimsOperations from ._operations import Operations from ._packet_core_control_planes_operations import PacketCoreControlPlanesOperations +from ._packet_core_control_plane_operations import PacketCoreControlPlaneOperations from ._packet_core_control_plane_versions_operations import PacketCoreControlPlaneVersionsOperations from ._packet_core_data_planes_operations import PacketCoreDataPlanesOperations from ._services_operations import ServicesOperations +from ._sims_operations import SimsOperations +from ._sim_operations import SimOperations +from ._sim_groups_operations import SimGroupsOperations from ._sim_policies_operations import SimPoliciesOperations +from ._sites_operations import SitesOperations from ._slices_operations import SlicesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AttachedDataNetworksOperations', - 'DataNetworksOperations', - 'MobileNetworksOperations', - 'SitesOperations', - 'SimGroupsOperations', - 'SimsOperations', - 'Operations', - 'PacketCoreControlPlanesOperations', - 'PacketCoreControlPlaneVersionsOperations', - 'PacketCoreDataPlanesOperations', - 'ServicesOperations', - 'SimPoliciesOperations', - 'SlicesOperations', + "AttachedDataNetworksOperations", + "DataNetworksOperations", + "MobileNetworksOperations", + "Operations", + "PacketCoreControlPlanesOperations", + "PacketCoreControlPlaneOperations", + "PacketCoreControlPlaneVersionsOperations", + "PacketCoreDataPlanesOperations", + "ServicesOperations", + "SimsOperations", + "SimOperations", + "SimGroupsOperations", + "SimPoliciesOperations", + "SitesOperations", + "SlicesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_attached_data_networks_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_attached_data_networks_operations.py index 676c3f6a57da..61521cb60af9 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_attached_data_networks_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_attached_data_networks_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,230 +29,307 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, attached_data_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "attachedDataNetworkName": _SERIALIZER.url("attached_data_network_name", attached_data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "attachedDataNetworkName": _SERIALIZER.url( + "attached_data_network_name", + attached_data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, attached_data_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "attachedDataNetworkName": _SERIALIZER.url("attached_data_network_name", attached_data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "attachedDataNetworkName": _SERIALIZER.url( + "attached_data_network_name", + attached_data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, attached_data_network_name: str, - *, - json: Optional[_models.AttachedDataNetwork] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "attachedDataNetworkName": _SERIALIZER.url("attached_data_network_name", attached_data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "attachedDataNetworkName": _SERIALIZER.url( + "attached_data_network_name", + attached_data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - subscription_id: str, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, attached_data_network_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "attachedDataNetworkName": _SERIALIZER.url("attached_data_network_name", attached_data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "attachedDataNetworkName": _SERIALIZER.url( + "attached_data_network_name", + attached_data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_packet_core_data_plane_request( - subscription_id: str, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AttachedDataNetworksOperations: """ @@ -266,7 +350,6 @@ 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 self, resource_group_name: str, @@ -276,50 +359,55 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, packet_core_control_plane_name: str, @@ -330,12 +418,13 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the specified attached data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_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. @@ -347,19 +436,18 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, @@ -367,37 +455,37 @@ def begin_delete( # pylint: disable=inconsistent-return-statements packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } @distributed_trace def get( @@ -411,49 +499,53 @@ def get( """Gets information about the specified attached data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AttachedDataNetwork, or the result of cls(response) + :return: AttachedDataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AttachedDataNetwork] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -461,15 +553,16 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } def _create_or_update_initial( self, @@ -477,65 +570,78 @@ def _create_or_update_initial( packet_core_control_plane_name: str, packet_core_data_plane_name: str, attached_data_network_name: str, - parameters: _models.AttachedDataNetwork, + parameters: Union[_models.AttachedDataNetwork, IO], **kwargs: Any ) -> _models.AttachedDataNetwork: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] - - _json = self._serialize.body(parameters, 'AttachedDataNetwork') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.AttachedDataNetwork] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachedDataNetwork") + + request = build_create_or_update_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -543,20 +649,114 @@ def begin_create_or_update( packet_core_data_plane_name: str, attached_data_network_name: str, parameters: _models.AttachedDataNetwork, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.AttachedDataNetwork]: - """Creates or updates an attached data network. + """Creates or updates an attached data network. Must be created in the same location as its parent + packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_name: str :param parameters: Parameters supplied to the create or update attached data network operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork + :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 AttachedDataNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AttachedDataNetwork]: + """Creates or updates an attached data network. Must be created in the same location as its parent + packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to the create or update attached data network operation. + Required. + :type parameters: IO + :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 AttachedDataNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: Union[_models.AttachedDataNetwork, IO], + **kwargs: Any + ) -> LROPoller[_models.AttachedDataNetwork]: + """Creates or updates an attached data network. Must be created in the same location as its parent + packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to the create or update attached data network operation. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork 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 @@ -568,22 +768,21 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either AttachedDataNetwork or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AttachedDataNetwork] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, @@ -591,41 +790,41 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, @@ -633,60 +832,144 @@ def update_tags( packet_core_data_plane_name: str, attached_data_network_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AttachedDataNetwork: """Updates an attached data network tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param attached_data_network_name: The name of the attached data network. + :param attached_data_network_name: The name of the attached data network. Required. :type attached_data_network_name: str - :param parameters: Parameters supplied to update attached data network tags. + :param parameters: Parameters supplied to update attached data network tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: AttachedDataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AttachedDataNetwork: + """Updates an attached data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to update attached data network tags. Required. + :type parameters: IO + :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: AttachedDataNetwork, or the result of cls(response) + :return: AttachedDataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.AttachedDataNetwork: + """Updates an attached data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. Required. + :type attached_data_network_name: str + :param parameters: Parameters supplied to update attached data network tags. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: AttachedDataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.AttachedDataNetwork + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetwork] + api_version: Literal["2022-11-01"] = 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.AttachedDataNetwork] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -694,15 +977,16 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + deserialized = self._deserialize("AttachedDataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}" + } @distributed_trace def list_by_packet_core_data_plane( @@ -711,62 +995,68 @@ def list_by_packet_core_data_plane( packet_core_control_plane_name: str, packet_core_data_plane_name: str, **kwargs: Any - ) -> Iterable[_models.AttachedDataNetworkListResult]: + ) -> Iterable["_models.AttachedDataNetwork"]: """Gets all the attached data networks associated with a packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AttachedDataNetworkListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.AttachedDataNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AttachedDataNetwork or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.AttachedDataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AttachedDataNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AttachedDataNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_packet_core_data_plane_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_packet_core_data_plane.metadata['url'], + template_url=self.list_by_packet_core_data_plane.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_packet_core_data_plane_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - packet_core_data_plane_name=packet_core_data_plane_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -774,16 +1064,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AttachedDataNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -794,8 +1082,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_packet_core_data_plane.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks"} # type: ignore + list_by_packet_core_data_plane.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_data_networks_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_data_networks_operations.py index 5c8e600fb70a..3bcff8dad74e 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_data_networks_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_data_networks_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,220 +29,228 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, mobile_network_name: str, data_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "dataNetworkName": _SERIALIZER.url("data_network_name", data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "dataNetworkName": _SERIALIZER.url( + "data_network_name", + data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, data_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "dataNetworkName": _SERIALIZER.url("data_network_name", data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "dataNetworkName": _SERIALIZER.url( + "data_network_name", + data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - *, - json: Optional[_models.DataNetwork] = None, - content: Any = None, - **kwargs: Any + _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, mobile_network_name: str, data_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "dataNetworkName": _SERIALIZER.url("data_network_name", data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "dataNetworkName": _SERIALIZER.url( + "data_network_name", + data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, data_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "dataNetworkName": _SERIALIZER.url("data_network_name", data_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "dataNetworkName": _SERIALIZER.url( + "data_network_name", + data_network_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_mobile_network_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DataNetworksOperations: """ @@ -256,71 +271,68 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, data_network_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, mobile_network_name: str, data_network_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_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. @@ -332,108 +344,107 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } @distributed_trace def get( - self, - resource_group_name: str, - mobile_network_name: str, - data_network_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, data_network_name: str, **kwargs: Any ) -> _models.DataNetwork: """Gets information about the specified data network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataNetwork, or the result of cls(response) + :return: DataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.DataNetwork] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,97 +452,199 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, data_network_name: str, - parameters: _models.DataNetwork, + parameters: Union[_models.DataNetwork, IO], **kwargs: Any ) -> _models.DataNetwork: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] - - _json = self._serialize.body(parameters, 'DataNetwork') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.DataNetwork] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataNetwork") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, data_network_name: str, parameters: _models.DataNetwork, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DataNetwork]: - """Creates or updates a data network. + """Creates or updates a data network. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_name: str :param parameters: Parameters supplied to the create or update data network operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.DataNetwork + :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 DataNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.DataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataNetwork]: + """Creates or updates a data network. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to the create or update data network operation. + Required. + :type parameters: IO + :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 DataNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.DataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: Union[_models.DataNetwork, IO], + **kwargs: Any + ) -> LROPoller[_models.DataNetwork]: + """Creates or updates a data network. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to the create or update data network operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.DataNetwork 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 @@ -543,120 +656,197 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either DataNetwork or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.DataNetwork] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataNetwork] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, mobile_network_name: str, data_network_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataNetwork: """Updates data network tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param data_network_name: The name of the data network. + :param data_network_name: The name of the data network. Required. :type data_network_name: str - :param parameters: Parameters supplied to update data network tags. + :param parameters: Parameters supplied to update data network tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: DataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataNetwork: + """Updates data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to update data network tags. Required. + :type parameters: IO + :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: DataNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.DataNetwork: + """Updates data network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param data_network_name: The name of the data network. Required. + :type data_network_name: str + :param parameters: Parameters supplied to update data network tags. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: DataNetwork, or the result of cls(response) + :return: DataNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.DataNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetwork] + api_version: Literal["2022-11-01"] = 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.DataNetwork] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, data_network_name=data_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -664,73 +854,79 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataNetwork', pipeline_response) + deserialized = self._deserialize("DataNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> Iterable[_models.DataNetworkListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> Iterable["_models.DataNetwork"]: """Lists all data networks in the mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataNetworkListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.DataNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataNetwork or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.DataNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.DataNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -738,16 +934,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -758,8 +952,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_mobile_networks_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_mobile_networks_operations.py index 47b10c70ddcf..61210042dd48 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_mobile_networks_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_mobile_networks_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,280 +29,221 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - *, - json: Optional[_models.MobileNetwork] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) + _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_update_tags_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) + _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_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sim_ids_request_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/listSimIds") # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MobileNetworksOperations: """ @@ -316,66 +264,63 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, mobile_network_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_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. @@ -387,103 +332,101 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> _models.MobileNetwork: + def get(self, resource_group_name: str, mobile_network_name: str, **kwargs: Any) -> _models.MobileNetwork: """Gets information about the specified mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MobileNetwork, or the result of cls(response) + :return: MobileNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.MobileNetwork] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -491,92 +434,185 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, - parameters: _models.MobileNetwork, + parameters: Union[_models.MobileNetwork, IO], **kwargs: Any ) -> _models.MobileNetwork: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] - - _json = self._serialize.body(parameters, 'MobileNetwork') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.MobileNetwork] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MobileNetwork") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, parameters: _models.MobileNetwork, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.MobileNetwork]: """Creates or updates a mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param parameters: Parameters supplied to the create or update mobile network operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.MobileNetwork + :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 MobileNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MobileNetwork]: + """Creates or updates a mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to the create or update mobile network operation. + Required. + :type parameters: IO + :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 MobileNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: Union[_models.MobileNetwork, IO], + **kwargs: Any + ) -> LROPoller[_models.MobileNetwork]: + """Creates or updates a mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to the create or update mobile network operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.MobileNetwork 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 @@ -588,115 +624,186 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either MobileNetwork or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.MobileNetwork] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MobileNetwork] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, mobile_network_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.MobileNetwork: """Updates mobile network tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param parameters: Parameters supplied to update mobile network tags. + :param parameters: Parameters supplied to update mobile network tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: MobileNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MobileNetwork: + """Updates mobile network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to update mobile network tags. Required. + :type parameters: IO + :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: MobileNetwork or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.MobileNetwork: + """Updates mobile network tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param parameters: Parameters supplied to update mobile network tags. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: MobileNetwork, or the result of cls(response) + :return: MobileNetwork or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.MobileNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetwork] + api_version: Literal["2022-11-01"] = 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.MobileNetwork] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -704,63 +811,70 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MobileNetwork', pipeline_response) + deserialized = self._deserialize("MobileNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.MobileNetworkListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.MobileNetwork"]: """Lists all the mobile networks in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MobileNetworkListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MobileNetwork or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.MobileNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -768,16 +882,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MobileNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -788,64 +900,69 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.MobileNetworkListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.MobileNetwork"]: """Lists all the mobile networks in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MobileNetworkListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetworkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MobileNetwork or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.MobileNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MobileNetworkListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.MobileNetworkListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -853,16 +970,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MobileNetworkListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -873,139 +988,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks"} # type: ignore - - def _list_sim_ids_initial( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> _models.SimIdListResult: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimIdListResult] - - - request = build_list_sim_ids_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=self._list_sim_ids_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('SimIdListResult', pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize('SimIdListResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _list_sim_ids_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/listSimIds"} # type: ignore - - - @distributed_trace - def begin_list_sim_ids( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> LROPoller[_models.SimIdListResult]: - """Lists the IDs of all provisioned SIMs in a mobile network. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. - :type mobile_network_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 SimIdListResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.SimIdListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimIdListResult] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._list_sim_ids_initial( # type: ignore - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SimIdListResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling - if cont_token: - return LROPoller.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) - - begin_list_sim_ids.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/listSimIds"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_operations.py index 1404ee8d0541..a8512ec8d19b 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.MobileNetwork/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,51 +79,58 @@ 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") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationList]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Gets a list of the operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -124,16 +138,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +156,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.MobileNetwork/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.MobileNetwork/operations"} diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_operations.py new file mode 100644 index 000000000000..0b9eb8408ffa --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_operations.py @@ -0,0 +1,676 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_rollback_request( + resource_group_name: str, packet_core_control_plane_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: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reinstall_request( + resource_group_name: str, packet_core_control_plane_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: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_collect_diagnostics_package_request( + resource_group_name: str, packet_core_control_plane_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: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PacketCoreControlPlaneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mobilenetwork.MobileNetworkManagementClient`'s + :attr:`packet_core_control_plane` 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") + + def _rollback_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_rollback_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rollback_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _rollback_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + @distributed_trace + def begin_rollback( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Roll back the specified packet core control plane to the previous version, "rollbackVersion". + Multiple consecutive rollbacks are not possible. This action may cause a service outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._rollback_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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_rollback.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + def _reinstall_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_reinstall_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reinstall_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _reinstall_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + @distributed_trace + def begin_reinstall( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Reinstall the specified packet core control plane. This action will remove any transaction + state from the packet core to return it to a known state. This action will cause a service + outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._reinstall_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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_reinstall.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + def _collect_diagnostics_package_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreControlPlaneCollectDiagnosticsPackage") + + request = build_collect_diagnostics_package_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._collect_diagnostics_package_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _collect_diagnostics_package_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } + + @overload + def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: _models.PacketCoreControlPlaneCollectDiagnosticsPackage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage 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. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._collect_diagnostics_package_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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_collect_diagnostics_package.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_versions_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_versions_operations.py index 631a533a1d8a..4d6e39b900ba 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_versions_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_versions_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse @@ -20,71 +27,62 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - version_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(version_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/{versionName}") path_format_arguments = { - "versionName": _SERIALIZER.url("version_name", version_name, 'str'), + "versionName": _SERIALIZER.url("version_name", version_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - **kwargs: Any -) -> HttpRequest: +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PacketCoreControlPlaneVersionsOperations: """ @@ -105,49 +103,47 @@ 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") - @distributed_trace - def get( - self, - version_name: str, - **kwargs: Any - ) -> _models.PacketCoreControlPlaneVersion: + def get(self, version_name: str, **kwargs: Any) -> _models.PacketCoreControlPlaneVersion: """Gets information about the specified packet core control plane version. - :param version_name: The name of the packet core control plane version. + :param version_name: The name of the packet core control plane version. Required. :type version_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PacketCoreControlPlaneVersion, or the result of cls(response) + :return: PacketCoreControlPlaneVersion or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneVersion] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneVersion] = kwargs.pop("cls", None) - request = build_get_request( version_name=version_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -155,62 +151,69 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreControlPlaneVersion', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlaneVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/{versionName}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/{versionName}"} @distributed_trace - def list_by_resource_group( - self, - **kwargs: Any - ) -> Iterable[_models.PacketCoreControlPlaneVersionListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.PacketCoreControlPlaneVersion"]: """Lists all supported packet core control planes versions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreControlPlaneVersionListResult or the - result of cls(response) + :return: An iterator like instance of either PacketCoreControlPlaneVersion or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneVersionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneVersionListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneVersionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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( + + request = build_list_request( api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -218,16 +221,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreControlPlaneVersionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -238,8 +239,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions"} diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py index 5f239e3243a4..a1477ad93b45 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,243 +29,237 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - resource_group_name: str, - packet_core_control_plane_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, packet_core_control_plane_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - packet_core_control_plane_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, packet_core_control_plane_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - resource_group_name: str, - packet_core_control_plane_name: str, - subscription_id: str, - *, - json: Optional[_models.PacketCoreControlPlane] = None, - content: Any = None, - **kwargs: Any + _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, packet_core_control_plane_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - resource_group_name: str, - packet_core_control_plane_name: str, - subscription_id: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, packet_core_control_plane_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + 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: +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PacketCoreControlPlanesOperations: """ @@ -279,66 +280,65 @@ 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 - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_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. @@ -350,103 +350,103 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } @distributed_trace def get( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any ) -> _models.PacketCoreControlPlane: """Gets information about the specified packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PacketCoreControlPlane, or the result of cls(response) + :return: PacketCoreControlPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlane] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -454,93 +454,185 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } def _create_or_update_initial( self, resource_group_name: str, packet_core_control_plane_name: str, - parameters: _models.PacketCoreControlPlane, + parameters: Union[_models.PacketCoreControlPlane, IO], **kwargs: Any ) -> _models.PacketCoreControlPlane: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] - - _json = self._serialize.body(parameters, 'PacketCoreControlPlane') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.PacketCoreControlPlane] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreControlPlane") + + request = build_create_or_update_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, packet_core_control_plane_name: str, parameters: _models.PacketCoreControlPlane, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PacketCoreControlPlane]: """Creates or updates a packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str :param parameters: Parameters supplied to the create or update packet core control plane - operation. + operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane + :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 PacketCoreControlPlane or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PacketCoreControlPlane]: + """Creates or updates a packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the create or update packet core control plane + operation. Required. + :type parameters: IO + :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 PacketCoreControlPlane or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlane, IO], + **kwargs: Any + ) -> LROPoller[_models.PacketCoreControlPlane]: + """Creates or updates a packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the create or update packet core control plane + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane 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 @@ -552,95 +644,166 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either PacketCoreControlPlane or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PacketCoreControlPlane] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, packet_core_control_plane_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PacketCoreControlPlane: """Updates packet core control planes tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to update packet core control plane tags. + :param parameters: Parameters supplied to update packet core control plane tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: PacketCoreControlPlane, or the result of cls(response) + :return: PacketCoreControlPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PacketCoreControlPlane: + """Updates packet core control planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to update packet core control plane tags. Required. + :type parameters: IO + :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: PacketCoreControlPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.PacketCoreControlPlane: + """Updates packet core control planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to update packet core control plane tags. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: PacketCoreControlPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlane] + api_version: Literal["2022-11-01"] = 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.PacketCoreControlPlane] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( resource_group_name=resource_group_name, @@ -649,18 +812,18 @@ def update_tags( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -668,64 +831,71 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreControlPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.PacketCoreControlPlaneListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.PacketCoreControlPlane"]: """Lists all the packet core control planes in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreControlPlaneListResult or the result of + :return: An iterator like instance of either PacketCoreControlPlane or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -733,16 +903,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreControlPlaneListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -753,65 +921,72 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes" + } @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.PacketCoreControlPlaneListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.PacketCoreControlPlane"]: """Lists all the packet core control planes in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreControlPlaneListResult or the result of + :return: An iterator like instance of either PacketCoreControlPlane or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreControlPlane] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreControlPlaneListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreControlPlaneListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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, - template_url=self.list_by_resource_group.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -819,16 +994,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreControlPlaneListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -839,8 +1012,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_data_planes_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_data_planes_operations.py index dd52a7774520..29a3dde152be 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_data_planes_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_data_planes_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,14 +29,21 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( + +def build_delete_request( resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, @@ -39,33 +53,44 @@ def build_delete_request_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -78,80 +103,97 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, subscription_id: str, - *, - json: Optional[_models.PacketCoreDataPlane] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( @@ -159,83 +201,92 @@ def build_update_tags_request( packet_core_control_plane_name: str, packet_core_data_plane_name: str, subscription_id: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "packetCoreDataPlaneName": _SERIALIZER.url("packet_core_data_plane_name", packet_core_data_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "packetCoreDataPlaneName": _SERIALIZER.url( + "packet_core_data_plane_name", + packet_core_data_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_packet_core_control_plane_request( - resource_group_name: str, - packet_core_control_plane_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, packet_core_control_plane_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "packetCoreControlPlaneName": _SERIALIZER.url("packet_core_control_plane_name", packet_core_control_plane_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PacketCoreDataPlanesOperations: """ @@ -256,7 +307,6 @@ 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 self, resource_group_name: str, @@ -265,49 +315,54 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, packet_core_control_plane_name: str, @@ -317,10 +372,11 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the specified packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_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. @@ -332,56 +388,55 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } @distributed_trace def get( @@ -394,46 +449,50 @@ def get( """Gets information about the specified packet core data plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PacketCoreDataPlane, or the result of cls(response) + :return: PacketCoreDataPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreDataPlane] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,39 +500,51 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } def _create_or_update_initial( self, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, - parameters: _models.PacketCoreDataPlane, + parameters: Union[_models.PacketCoreDataPlane, IO], **kwargs: Any ) -> _models.PacketCoreDataPlane: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] - - _json = self._serialize.body(parameters, 'PacketCoreDataPlane') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.PacketCoreDataPlane] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreDataPlane") + + request = build_create_or_update_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, @@ -481,58 +552,67 @@ def _create_or_update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, parameters: _models.PacketCoreDataPlane, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PacketCoreDataPlane]: - """Creates or updates a packet core data plane. + """Creates or updates a packet core data plane. Must be created in the same location as its parent + packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str :param parameters: Parameters supplied to the create or update packet core data plane - operation. + operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane + :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 @@ -544,99 +624,256 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either PacketCoreDataPlane or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PacketCoreDataPlane]: + """Creates or updates a packet core data plane. Must be created in the same location as its parent + packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to the create or update packet core data plane + operation. Required. + :type parameters: IO + :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 PacketCoreDataPlane or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: Union[_models.PacketCoreDataPlane, IO], + **kwargs: Any + ) -> LROPoller[_models.PacketCoreDataPlane]: + """Creates or updates a packet core data plane. Must be created in the same location as its parent + packet core control plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to the create or update packet core data plane + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane 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. + :return: An instance of LROPoller that returns either PacketCoreDataPlane or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PacketCoreDataPlane] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, packet_core_data_plane_name=packet_core_data_plane_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, packet_core_control_plane_name: str, packet_core_data_plane_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PacketCoreDataPlane: """Updates packet core data planes tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str - :param packet_core_data_plane_name: The name of the packet core data plane. + :param packet_core_data_plane_name: The name of the packet core data plane. Required. :type packet_core_data_plane_name: str - :param parameters: Parameters supplied to update packet core data plane tags. + :param parameters: Parameters supplied to update packet core data plane tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: PacketCoreDataPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PacketCoreDataPlane: + """Updates packet core data planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to update packet core data plane tags. Required. + :type parameters: IO + :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: PacketCoreDataPlane or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.PacketCoreDataPlane: + """Updates packet core data planes tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. Required. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to update packet core data plane tags. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: PacketCoreDataPlane, or the result of cls(response) + :return: PacketCoreDataPlane or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlane] + api_version: Literal["2022-11-01"] = 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.PacketCoreDataPlane] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( resource_group_name=resource_group_name, @@ -646,18 +883,18 @@ def update_tags( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -665,74 +902,79 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + deserialized = self._deserialize("PacketCoreDataPlane", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}" + } @distributed_trace def list_by_packet_core_control_plane( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - **kwargs: Any - ) -> Iterable[_models.PacketCoreDataPlaneListResult]: + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Iterable["_models.PacketCoreDataPlane"]: """Lists all the packet core data planes associated with a packet core control plane. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. + :param packet_core_control_plane_name: The name of the packet core control plane. Required. :type packet_core_control_plane_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PacketCoreDataPlaneListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlaneListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PacketCoreDataPlane or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.PacketCoreDataPlane] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PacketCoreDataPlaneListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PacketCoreDataPlaneListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_packet_core_control_plane_request( resource_group_name=resource_group_name, packet_core_control_plane_name=packet_core_control_plane_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_packet_core_control_plane.metadata['url'], + template_url=self.list_by_packet_core_control_plane.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_packet_core_control_plane_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -740,16 +982,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PacketCoreDataPlaneListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -760,8 +1000,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_packet_core_control_plane.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes"} # type: ignore + list_by_packet_core_control_plane.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_patch.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_patch.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_services_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_services_operations.py index ca6307a5b877..4c1ead59af25 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_services_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_services_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,220 +29,228 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - resource_group_name: str, - mobile_network_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, mobile_network_name: str, service_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=64, min_length=0, pattern=r'^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=64, + pattern=r"^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - mobile_network_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, service_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=64, min_length=0, pattern=r'^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=64, + pattern=r"^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - resource_group_name: str, - mobile_network_name: str, - service_name: str, - subscription_id: str, - *, - json: Optional[_models.Service] = None, - content: Any = None, - **kwargs: Any + _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, mobile_network_name: str, service_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=64, min_length=0, pattern=r'^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=64, + pattern=r"^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - service_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, service_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=64, min_length=0, pattern=r'^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=64, + pattern=r"^(?!(default|requested|service)$)[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_mobile_network_request( - resource_group_name: str, - mobile_network_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ServicesOperations: """ @@ -256,72 +271,69 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, service_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - service_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, mobile_network_name: str, service_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_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. @@ -333,109 +345,108 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } @distributed_trace def get( - self, - resource_group_name: str, - mobile_network_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, service_name: str, **kwargs: Any ) -> _models.Service: """Gets information about the specified service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Service, or the result of cls(response) + :return: Service or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Service - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Service] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,39 +454,51 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, service_name: str, - parameters: _models.Service, + parameters: Union[_models.Service, IO], **kwargs: Any ) -> _models.Service: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] - - _json = self._serialize.body(parameters, 'Service') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.Service] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Service") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, @@ -483,58 +506,146 @@ def _create_or_update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, service_name: str, parameters: _models.Service, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Service]: - """Creates or updates a service. + """Creates or updates a service. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_name: str - :param parameters: Parameters supplied to the create or update service operation. + :param parameters: Parameters supplied to the create or update service operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Service + :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 Service or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Service] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Service]: + """Creates or updates a service. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to the create or update service operation. Required. + :type parameters: IO + :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 Service or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Service] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: Union[_models.Service, IO], + **kwargs: Any + ) -> LROPoller[_models.Service]: + """Creates or updates a service. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to the create or update service operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Service 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 @@ -545,121 +656,200 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either Service or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Service] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Service] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, mobile_network_name: str, service_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Updates service tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :param service_name: The name of the service. You must not use any of the following reserved - strings - ``default``\ , ``requested`` or ``service``. + strings - ``default``\ , ``requested`` or ``service``. Required. :type service_name: str - :param parameters: Parameters supplied to update service tags. + :param parameters: Parameters supplied to update service tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: Service or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Service + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Service: + """Updates service tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to update service tags. Required. + :type parameters: IO + :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: Service or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Service + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.Service: + """Updates service tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. Required. + :type service_name: str + :param parameters: Parameters supplied to update service tags. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: Service, or the result of cls(response) + :return: Service or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Service - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Service] + api_version: Literal["2022-11-01"] = 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.Service] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,72 +857,79 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Service', pipeline_response) + deserialized = self._deserialize("Service", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> Iterable[_models.ServiceListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> Iterable["_models.Service"]: """Gets all the services in a mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServiceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.ServiceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Service or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.Service] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ServiceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -740,16 +937,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -760,8 +955,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_groups_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_groups_operations.py index 4225b82de392..c56d43ab9c41 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_groups_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_groups_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,243 +29,219 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any + resource_group_name: str, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - subscription_id: str, - resource_group_name: str, - sim_group_name: str, - *, - json: Optional[_models.SimGroup] = None, - content: Any = None, - **kwargs: Any + _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, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/simGroups/{simGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - subscription_id: str, - resource_group_name: str, - sim_group_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/simGroups/{simGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/simGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + 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: +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SimGroupsOperations: """ @@ -279,66 +262,63 @@ 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 - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any + self, resource_group_name: str, sim_group_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, sim_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_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. @@ -350,103 +330,101 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, sim_group_name=sim_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any - ) -> _models.SimGroup: + def get(self, resource_group_name: str, sim_group_name: str, **kwargs: Any) -> _models.SimGroup: """Gets information about the specified SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimGroup, or the result of cls(response) + :return: SimGroup or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimGroup] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -454,92 +432,143 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } def _create_or_update_initial( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.SimGroup, - **kwargs: Any + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimGroup, IO], **kwargs: Any ) -> _models.SimGroup: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] - - _json = self._serialize.body(parameters, 'SimGroup') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.SimGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimGroup") + + request = build_create_or_update_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, sim_group_name: str, parameters: _models.SimGroup, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SimGroup]: """Creates or updates a SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param parameters: Parameters supplied to the create or update SIM group operation. + :param parameters: Parameters supplied to the create or update SIM group operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.SimGroup + :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 SimGroup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SimGroup]: + """Creates or updates a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the create or update SIM group operation. Required. + :type parameters: IO + :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 @@ -550,115 +579,212 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either SimGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.SimGroup] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimGroup, IO], **kwargs: Any + ) -> LROPoller[_models.SimGroup]: + """Creates or updates a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the create or update SIM group operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimGroup 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. + :return: An instance of LROPoller that returns either SimGroup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SimGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, sim_group_name=sim_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/simGroups/{simGroupName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, sim_group_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SimGroup: """Updates SIM group tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param parameters: Parameters supplied to update SIM group tags. + :param parameters: Parameters supplied to update SIM group tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: SimGroup or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SimGroup: + """Updates SIM group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to update SIM group tags. Required. + :type parameters: IO + :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: SimGroup, or the result of cls(response) + :return: SimGroup or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + ) -> _models.SimGroup: + """Updates SIM group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to update SIM group tags. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: SimGroup or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimGroup + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroup] + api_version: Literal["2022-11-01"] = 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.SimGroup] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,62 +792,70 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimGroup', pipeline_response) + deserialized = self._deserialize("SimGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.SimGroupListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SimGroup"]: """Gets all the SIM groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SimGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SimGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SimGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroupListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimGroupListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -729,16 +863,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SimGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -749,63 +881,69 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/simGroups"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/simGroups" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SimGroupListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SimGroup"]: """Gets all the SIM groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SimGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SimGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SimGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SimGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimGroupListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimGroupListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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, - template_url=self.list_by_resource_group.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -813,16 +951,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SimGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -833,8 +969,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_operations.py new file mode 100644 index 000000000000..7df28e3a708a --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_operations.py @@ -0,0 +1,846 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_bulk_upload_request( + resource_group_name: str, sim_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: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/simGroups/{simGroupName}/uploadSims", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _format_url_section(_url, **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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_bulk_delete_request( + resource_group_name: str, sim_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: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/simGroups/{simGroupName}/deleteSims", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _format_url_section(_url, **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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_bulk_upload_encrypted_request( + resource_group_name: str, sim_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: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _format_url_section(_url, **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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SimOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mobilenetwork.MobileNetworkManagementClient`'s + :attr:`sim` 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") + + def _bulk_upload_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimUploadList") + + request = build_bulk_upload_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + @overload + def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_bulk_upload( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList 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. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._bulk_upload_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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_bulk_upload.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + def _bulk_delete_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimDeleteList") + + request = build_bulk_delete_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + @overload + def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimDeleteList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_bulk_delete( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList 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. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._bulk_delete_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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_bulk_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + def _bulk_upload_encrypted_initial( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 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: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "EncryptedSimUploadList") + + request = build_bulk_upload_encrypted_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_encrypted_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_encrypted_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } + + @overload + def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.EncryptedSimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: IO + :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 AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList 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. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = 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.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._bulk_upload_encrypted_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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_bulk_upload_encrypted.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_policies_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_policies_operations.py index a14cd754b4ae..5fd67faa146d 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_policies_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_policies_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,220 +29,212 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, mobile_network_name: str, sim_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "simPolicyName": _SERIALIZER.url("sim_policy_name", sim_policy_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "simPolicyName": _SERIALIZER.url( + "sim_policy_name", sim_policy_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, sim_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "simPolicyName": _SERIALIZER.url("sim_policy_name", sim_policy_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "simPolicyName": _SERIALIZER.url( + "sim_policy_name", sim_policy_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - subscription_id: str, - *, - json: Optional[_models.SimPolicy] = None, - content: Any = None, - **kwargs: Any + _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, mobile_network_name: str, sim_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "simPolicyName": _SERIALIZER.url("sim_policy_name", sim_policy_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "simPolicyName": _SERIALIZER.url( + "sim_policy_name", sim_policy_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, sim_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "simPolicyName": _SERIALIZER.url("sim_policy_name", sim_policy_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "simPolicyName": _SERIALIZER.url( + "sim_policy_name", sim_policy_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_mobile_network_request( - resource_group_name: str, - mobile_network_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SimPoliciesOperations: """ @@ -256,71 +255,68 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified SIM policy. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_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. @@ -332,108 +328,107 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } @distributed_trace def get( - self, - resource_group_name: str, - mobile_network_name: str, - sim_policy_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, **kwargs: Any ) -> _models.SimPolicy: """Gets information about the specified SIM policy. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimPolicy, or the result of cls(response) + :return: SimPolicy or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimPolicy] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,39 +436,51 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, - parameters: _models.SimPolicy, + parameters: Union[_models.SimPolicy, IO], **kwargs: Any ) -> _models.SimPolicy: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] - - _json = self._serialize.body(parameters, 'SimPolicy') - - request = build_create_or_update_request_initial( + api_version: Literal["2022-11-01"] = 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.SimPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimPolicy") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, @@ -481,57 +488,143 @@ def _create_or_update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, parameters: _models.SimPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SimPolicy]: - """Creates or updates a SIM policy. + """Creates or updates a SIM policy. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_name: str - :param parameters: Parameters supplied to the create or update SIM policy operation. + :param parameters: Parameters supplied to the create or update SIM policy operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.SimPolicy + :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 SimPolicy or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.SimPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SimPolicy]: + """Creates or updates a SIM policy. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to the create or update SIM policy operation. Required. + :type parameters: IO + :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 SimPolicy or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.SimPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: Union[_models.SimPolicy, IO], + **kwargs: Any + ) -> LROPoller[_models.SimPolicy]: + """Creates or updates a SIM policy. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to the create or update SIM policy operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimPolicy 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 @@ -542,120 +635,197 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either SimPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.SimPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SimPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, mobile_network_name: str, sim_policy_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SimPolicy: """Updates SIM policy tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param sim_policy_name: The name of the SIM policy. + :param sim_policy_name: The name of the SIM policy. Required. :type sim_policy_name: str - :param parameters: Parameters supplied to update SIM policy tags. + :param parameters: Parameters supplied to update SIM policy tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: SimPolicy or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SimPolicy: + """Updates SIM policy tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to update SIM policy tags. Required. + :type parameters: IO + :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: SimPolicy or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.SimPolicy: + """Updates SIM policy tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. Required. + :type sim_policy_name: str + :param parameters: Parameters supplied to update SIM policy tags. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 - :return: SimPolicy, or the result of cls(response) + :return: SimPolicy or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.SimPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicy] + api_version: Literal["2022-11-01"] = 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.SimPolicy] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, sim_policy_name=sim_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -663,72 +833,79 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SimPolicy', pipeline_response) + deserialized = self._deserialize("SimPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> Iterable[_models.SimPolicyListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> Iterable["_models.SimPolicy"]: """Gets all the SIM policies in a mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SimPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SimPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SimPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SimPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimPolicyListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimPolicyListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -736,16 +913,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SimPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -756,8 +931,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py index 50fdf6d72cc5..87fcd7093275 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,173 +29,165 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, sim_group_name: str, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "simName": _SERIALIZER.url("sim_name", sim_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "simName": _SERIALIZER.url("sim_name", sim_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any + resource_group_name: str, sim_group_name: str, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "simName": _SERIALIZER.url("sim_name", sim_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "simName": _SERIALIZER.url("sim_name", sim_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - subscription_id: str, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - *, - json: Optional[_models.Sim] = None, - content: Any = None, - **kwargs: Any + _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, sim_group_name: str, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/simGroups/{simGroupName}/sims/{simName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "simName": _SERIALIZER.url("sim_name", sim_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "simName": _SERIALIZER.url("sim_name", sim_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_sim_group_request( - resource_group_name: str, - subscription_id: str, - sim_group_name: str, - **kwargs: Any + _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_list_by_group_request( + resource_group_name: str, sim_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "simGroupName": _SERIALIZER.url("sim_group_name", sim_group_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SimsOperations: """ @@ -209,71 +208,68 @@ 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 - self, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any + self, resource_group_name: str, sim_group_name: str, sim_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, sim_group_name: str, sim_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified SIM. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param sim_name: The name of the SIM. + :param sim_name: The name of the SIM. Required. :type sim_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. @@ -285,108 +281,105 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - sim_group_name: str, - sim_name: str, - **kwargs: Any - ) -> _models.Sim: + def get(self, resource_group_name: str, sim_group_name: str, sim_name: str, **kwargs: Any) -> _models.Sim: """Gets information about the specified SIM. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param sim_name: The name of the SIM. + :param sim_name: The name of the SIM. Required. :type sim_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Sim, or the result of cls(response) + :return: Sim or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Sim - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Sim] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Sim] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -394,97 +387,117 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } def _create_or_update_initial( self, resource_group_name: str, sim_group_name: str, sim_name: str, - parameters: _models.Sim, + parameters: Union[_models.Sim, IO], **kwargs: Any ) -> _models.Sim: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Sim] - - _json = self._serialize.body(parameters, 'Sim') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.Sim] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Sim") + + request = build_create_or_update_request( resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, sim_group_name: str, sim_name: str, parameters: _models.Sim, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Sim]: """Creates or updates a SIM. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_group_name: str - :param sim_name: The name of the SIM. + :param sim_name: The name of the SIM. Required. :type sim_name: str - :param parameters: Parameters supplied to the create or update SIM operation. + :param parameters: Parameters supplied to the create or update SIM operation. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Sim + :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 @@ -495,118 +508,196 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either Sim or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Sim] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + sim_group_name: str, + sim_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Sim]: + """Creates or updates a SIM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param sim_name: The name of the SIM. Required. + :type sim_name: str + :param parameters: Parameters supplied to the create or update SIM operation. Required. + :type parameters: IO + :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 Sim or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Sim] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + sim_group_name: str, + sim_name: str, + parameters: Union[_models.Sim, IO], + **kwargs: Any + ) -> LROPoller[_models.Sim]: + """Creates or updates a SIM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param sim_name: The name of the SIM. Required. + :type sim_name: str + :param parameters: Parameters supplied to the create or update SIM operation. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Sim 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. + :return: An instance of LROPoller that returns either Sim or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Sim] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Sim] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Sim] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, sim_group_name=sim_group_name, sim_name=sim_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Sim', pipeline_response) + deserialized = self._deserialize("Sim", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/simGroups/{simGroupName}/sims/{simName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims/{simName}" + } @distributed_trace - def list_by_sim_group( - self, - resource_group_name: str, - sim_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SimListResult]: + def list_by_group(self, resource_group_name: str, sim_group_name: str, **kwargs: Any) -> Iterable["_models.Sim"]: """Gets all the SIMs in a SIM group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. + :param sim_group_name: The name of the SIM Group. Required. :type sim_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 SimListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SimListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sim or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.Sim] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SimListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SimListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_list_by_sim_group_request( + + request = build_list_by_group_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sim_group.metadata['url'], + template_url=self.list_by_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_sim_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - sim_group_name=sim_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -614,16 +705,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SimListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -634,8 +723,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_sim_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims"} # type: ignore + list_by_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sites_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sites_operations.py index 5b137feab348..69793972cdb8 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sites_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sites_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,220 +29,212 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, mobile_network_name: str, site_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "siteName": _SERIALIZER.url("site_name", site_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, site_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "siteName": _SERIALIZER.url("site_name", site_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - *, - json: Optional[_models.Site] = None, - content: Any = None, - **kwargs: Any + _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, mobile_network_name: str, site_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "siteName": _SERIALIZER.url("site_name", site_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, site_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "siteName": _SERIALIZER.url("site_name", site_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_mobile_network_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SitesOperations: """ @@ -256,71 +255,69 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, site_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, mobile_network_name: str, site_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes the specified mobile network site. + """Deletes the specified mobile network site. This will also delete any network functions that are + a part of this site. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_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. @@ -332,108 +329,105 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - mobile_network_name: str, - site_name: str, - **kwargs: Any - ) -> _models.Site: + def get(self, resource_group_name: str, mobile_network_name: str, site_name: str, **kwargs: Any) -> _models.Site: """Gets information about the specified mobile network site. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Site, or the result of cls(response) + :return: Site or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Site - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,97 +435,159 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, site_name: str, - parameters: _models.Site, + parameters: Union[_models.Site, IO], **kwargs: Any ) -> _models.Site: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] - - _json = self._serialize.body(parameters, 'Site') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.Site] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Site") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, site_name: str, parameters: _models.Site, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Site]: - """Creates or updates a mobile network site. + """Creates or updates a mobile network site. Must be created in the same location as its parent + mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_name: str :param parameters: Parameters supplied to the create or update mobile network site operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Site + :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 Site or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Site]: + """Creates or updates a mobile network site. Must be created in the same location as its parent + mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update mobile network site operation. + Required. + :type parameters: IO + :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 @@ -542,120 +598,235 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either Site or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Site] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: Union[_models.Site, IO], + **kwargs: Any + ) -> LROPoller[_models.Site]: + """Creates or updates a mobile network site. Must be created in the same location as its parent + mobile network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update mobile network site operation. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Site 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. + :return: An instance of LROPoller that returns either Site or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, mobile_network_name: str, site_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Site: """Updates site tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param site_name: The name of the mobile network site. + :param site_name: The name of the mobile network site. Required. :type site_name: str - :param parameters: Parameters supplied to update network site tags. + :param parameters: Parameters supplied to update network site tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: Site or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Site: + """Updates site tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: IO + :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: Site, or the result of cls(response) + :return: Site or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Site - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.Site: + """Updates site tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: Site or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Site] + api_version: Literal["2022-11-01"] = 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.Site] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, site_name=site_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -663,72 +834,79 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Site', pipeline_response) + deserialized = self._deserialize("Site", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> Iterable[_models.SiteListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> Iterable["_models.Site"]: """Lists all sites in the mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SiteListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SiteListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Site or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SiteListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SiteListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -736,16 +914,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SiteListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -756,8 +932,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_slices_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_slices_operations.py index c357482abf9f..e070fefe0167 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_slices_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_slices_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.pipeline.transport import HttpResponse @@ -22,220 +29,212 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, mobile_network_name: str, slice_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "sliceName": _SERIALIZER.url("slice_name", slice_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "sliceName": _SERIALIZER.url( + "slice_name", slice_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, slice_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "sliceName": _SERIALIZER.url("slice_name", slice_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "sliceName": _SERIALIZER.url( + "slice_name", slice_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_initial( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - *, - json: Optional[_models.Slice] = None, - content: Any = None, - **kwargs: Any + _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, mobile_network_name: str, slice_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "sliceName": _SERIALIZER.url("slice_name", slice_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "sliceName": _SERIALIZER.url( + "slice_name", slice_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - *, - json: Optional[_models.TagsObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, mobile_network_name: str, slice_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), - "sliceName": _SERIALIZER.url("slice_name", slice_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "sliceName": _SERIALIZER.url( + "slice_name", slice_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_mobile_network_request( - subscription_id: str, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any + resource_group_name: str, mobile_network_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "mobileNetworkName": _SERIALIZER.url("mobile_network_name", mobile_network_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "mobileNetworkName": _SERIALIZER.url( + "mobile_network_name", mobile_network_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SlicesOperations: """ @@ -256,71 +255,68 @@ 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 - self, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any + self, resource_group_name: str, mobile_network_name: str, slice_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, mobile_network_name: str, slice_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified network slice. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_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. @@ -332,108 +328,105 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - mobile_network_name: str, - slice_name: str, - **kwargs: Any - ) -> _models.Slice: + def get(self, resource_group_name: str, mobile_network_name: str, slice_name: str, **kwargs: Any) -> _models.Slice: """Gets information about the specified network slice. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Slice, or the result of cls(response) + :return: Slice or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Slice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Slice] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,97 +434,197 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } def _create_or_update_initial( self, resource_group_name: str, mobile_network_name: str, slice_name: str, - parameters: _models.Slice, + parameters: Union[_models.Slice, IO], **kwargs: Any ) -> _models.Slice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] - - _json = self._serialize.body(parameters, 'Slice') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-11-01"] = 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.Slice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Slice") + + request = build_create_or_update_request( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore + return deserialized # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, mobile_network_name: str, slice_name: str, parameters: _models.Slice, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Slice]: - """Creates or updates a network slice. + """Creates or updates a network slice. Must be created in the same location as its parent mobile + network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_name: str :param parameters: Parameters supplied to the create or update network slice operation. + Required. :type parameters: ~azure.mgmt.mobilenetwork.models.Slice + :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 Slice or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Slice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Slice]: + """Creates or updates a network slice. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to the create or update network slice operation. + Required. + :type parameters: IO + :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 Slice or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Slice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: Union[_models.Slice, IO], + **kwargs: Any + ) -> LROPoller[_models.Slice]: + """Creates or updates a network slice. Must be created in the same location as its parent mobile + network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to the create or update network slice operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.Slice 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 @@ -542,120 +635,197 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either Slice or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.Slice] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Slice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } - @distributed_trace + @overload def update_tags( self, resource_group_name: str, mobile_network_name: str, slice_name: str, parameters: _models.TagsObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Slice: """Updates slice tags. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str - :param slice_name: The name of the network slice. + :param slice_name: The name of the network slice. Required. :type slice_name: str - :param parameters: Parameters supplied to update network slice tags. + :param parameters: Parameters supplied to update network slice tags. Required. :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject + :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: Slice or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Slice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Slice: + """Updates slice tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to update network slice tags. Required. + :type parameters: IO + :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: Slice, or the result of cls(response) + :return: Slice or the result of cls(response) :rtype: ~azure.mgmt.mobilenetwork.models.Slice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.Slice: + """Updates slice tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. Required. + :type mobile_network_name: str + :param slice_name: The name of the network slice. Required. + :type slice_name: str + :param parameters: Parameters supplied to update network slice tags. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.TagsObject 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 + :return: Slice or the result of cls(response) + :rtype: ~azure.mgmt.mobilenetwork.models.Slice + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Slice] + api_version: Literal["2022-11-01"] = 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.Slice] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TagsObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") request = build_update_tags_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, slice_name=slice_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -663,72 +833,79 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Slice', pipeline_response) + deserialized = self._deserialize("Slice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}"} # type: ignore - + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}" + } @distributed_trace def list_by_mobile_network( - self, - resource_group_name: str, - mobile_network_name: str, - **kwargs: Any - ) -> Iterable[_models.SliceListResult]: + self, resource_group_name: str, mobile_network_name: str, **kwargs: Any + ) -> Iterable["_models.Slice"]: """Lists all slices in the mobile network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param mobile_network_name: The name of the mobile network. + :param mobile_network_name: The name of the mobile network. Required. :type mobile_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SliceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.SliceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Slice or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mobilenetwork.models.Slice] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SliceListResult] + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.SliceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, mobile_network_name=mobile_network_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_mobile_network.metadata['url'], + template_url=self.list_by_mobile_network.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_mobile_network_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - mobile_network_name=mobile_network_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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 = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -736,16 +913,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SliceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -756,8 +931,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_mobile_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices"} # type: ignore + list_by_mobile_network.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_create.py new file mode 100644 index 000000000000..8b6c32f6046b --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_create.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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python attached_data_network_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.attached_data_networks.begin_create_or_update( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + packet_core_data_plane_name="TestPacketCoreDP", + attached_data_network_name="TestAttachedDataNetwork", + parameters={ + "location": "eastus", + "properties": { + "dnsAddresses": ["1.1.1.1"], + "naptConfiguration": { + "enabled": "Enabled", + "pinholeLimits": 65536, + "pinholeTimeouts": {"icmp": 30, "tcp": 180, "udp": 30}, + "portRange": {"maxPort": 49999, "minPort": 1024}, + "portReuseHoldTime": {"tcp": 120, "udp": 60}, + }, + "userEquipmentAddressPoolPrefix": ["2.2.0.0/16"], + "userEquipmentStaticAddressPoolPrefix": ["2.4.0.0/16"], + "userPlaneDataInterface": {"name": "N6"}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_delete.py new file mode 100644 index 000000000000..7fca1132eddc --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python attached_data_network_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.attached_data_networks.begin_delete( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + packet_core_data_plane_name="TestPacketCoreDP", + attached_data_network_name="TestAttachedDataNetwork", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_get.py new file mode 100644 index 000000000000..3ee86f800208 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_get.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python attached_data_network_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.attached_data_networks.get( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + packet_core_data_plane_name="TestPacketCoreDP", + attached_data_network_name="TestAttachedDataNetwork", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_list_by_packet_core_data_plane.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_list_by_packet_core_data_plane.py new file mode 100644 index 000000000000..050007481233 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_list_by_packet_core_data_plane.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python attached_data_network_list_by_packet_core_data_plane.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.attached_data_networks.list_by_packet_core_data_plane( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + packet_core_data_plane_name="TestPacketCoreDP", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkListByPacketCoreDataPlane.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_update_tags.py new file mode 100644 index 000000000000..30045053ebed --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/attached_data_network_update_tags.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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python attached_data_network_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.attached_data_networks.update_tags( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + packet_core_data_plane_name="TestPacketCoreDP", + attached_data_network_name="TestAttachedDataNetwork", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/AttachedDataNetworkUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_create.py new file mode 100644 index 000000000000..6c1d68c3dd94 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_create.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python data_network_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.data_networks.begin_create_or_update( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + data_network_name="testDataNetwork", + parameters={"location": "eastus", "properties": {"description": "myFavouriteDataNetwork"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_delete.py new file mode 100644 index 000000000000..9737f70aa5a6 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python data_network_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.data_networks.begin_delete( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + data_network_name="testDataNetwork", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_get.py new file mode 100644 index 000000000000..ecc4e60d471f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python data_network_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.data_networks.get( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + data_network_name="testDataNetwork", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_list_by_mobile_network.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_list_by_mobile_network.py new file mode 100644 index 000000000000..d25bf96da424 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_list_by_mobile_network.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python data_network_list_by_mobile_network.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.data_networks.list_by_mobile_network( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkListByMobileNetwork.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_update_tags.py new file mode 100644 index 000000000000..a2d7d192ed68 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/data_network_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python data_network_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.data_networks.update_tags( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + data_network_name="testDataNetwork", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/DataNetworkUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_create.py new file mode 100644 index 000000000000..b0ebb0fcf120 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_create.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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python mobile_network_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.mobile_networks.begin_create_or_update( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + parameters={ + "location": "eastus", + "properties": {"publicLandMobileNetworkIdentifier": {"mcc": "001", "mnc": "01"}}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_delete.py new file mode 100644 index 000000000000..19a992c0f7d4 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python mobile_network_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.mobile_networks.begin_delete( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_get.py new file mode 100644 index 000000000000..259045c0dbb9 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_get.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python mobile_network_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.mobile_networks.get( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_list_by_resource_group.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_list_by_resource_group.py new file mode 100644 index 000000000000..302bc4cbc60a --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_list_by_resource_group.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python mobile_network_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.mobile_networks.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_list_by_subscription.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_list_by_subscription.py new file mode 100644 index 000000000000..24df6552f3a0 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python mobile_network_list_by_subscription.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.mobile_networks.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_update_tags.py new file mode 100644 index 000000000000..34f64a6fae98 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/mobile_network_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python mobile_network_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.mobile_networks.update_tags( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/MobileNetworkUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/operation_list.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/operation_list.py new file mode 100644 index 000000000000..3f7a877944e5 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/operation_list.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python operation_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/OperationList.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_collect_diagnostics_package.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_collect_diagnostics_package.py new file mode 100644 index 000000000000..f12ed92c7bf4 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_collect_diagnostics_package.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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_collect_diagnostics_package.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_plane.begin_collect_diagnostics_package( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + parameters={ + "storageAccountBlobUrl": "https://contosoaccount.blob.core.windows.net/container/diagnosticsPackage.zip" + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneCollectDiagnosticsPackage.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_create.py new file mode 100644 index 000000000000..23223fe1d683 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_create.py @@ -0,0 +1,74 @@ +# 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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_planes.begin_create_or_update( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + parameters={ + "location": "eastus", + "properties": { + "controlPlaneAccessInterface": {"name": "N2"}, + "coreNetworkTechnology": "5GC", + "localDiagnosticsAccess": { + "authenticationType": "AAD", + "httpsServerCertificate": { + "certificateUrl": "https://contosovault.vault.azure.net/certificates/ingress" + }, + }, + "platform": { + "azureStackEdgeDevice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice" + }, + "connectedCluster": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster" + }, + "customLocation": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation" + }, + "type": "AKS-HCI", + }, + "sites": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite" + } + ], + "sku": "G0", + "ueMtu": 1600, + "version": "0.2.0", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_delete.py new file mode 100644 index 000000000000..46dfcb714e62 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_planes.begin_delete( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_get.py new file mode 100644 index 000000000000..c1ebb51960fa --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_get.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_planes.get( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_list_by_resource_group.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_list_by_resource_group.py new file mode 100644 index 000000000000..2f2bf100372a --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_list_by_resource_group.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_planes.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_list_by_subscription.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_list_by_subscription.py new file mode 100644 index 000000000000..0d005535c9b7 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_list_by_subscription.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_planes.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_reinstall.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_reinstall.py new file mode 100644 index 000000000000..c9c09667f10c --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_reinstall.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_reinstall.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_plane.begin_reinstall( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneReinstall.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_rollback.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_rollback.py new file mode 100644 index 000000000000..e74d736a73fb --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_rollback.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_rollback.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_plane.begin_rollback( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneRollback.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_update_tags.py new file mode 100644 index 000000000000..c45d7a70b676 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_control_planes.update_tags( + resource_group_name="rg1", + packet_core_control_plane_name="TestPacketCoreCP", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_version_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_version_get.py new file mode 100644 index 000000000000..4f8772d55fac --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_version_get.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_version_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.packet_core_control_plane_versions.get( + version_name="PMN-4-11-1", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneVersionGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_version_list.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_version_list.py new file mode 100644 index 000000000000..141859e2c21f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_version_list.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_control_plane_version_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.packet_core_control_plane_versions.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreControlPlaneVersionList.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_create.py new file mode 100644 index 000000000000..3944528a0c88 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_create.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_data_plane_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_data_planes.begin_create_or_update( + resource_group_name="rg1", + packet_core_control_plane_name="testPacketCoreCP", + packet_core_data_plane_name="testPacketCoreDP", + parameters={"location": "eastus", "properties": {"userPlaneAccessInterface": {"name": "N3"}}}, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_delete.py new file mode 100644 index 000000000000..72a5ae33ab23 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_data_plane_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_data_planes.begin_delete( + resource_group_name="rg1", + packet_core_control_plane_name="testPacketCoreCP", + packet_core_data_plane_name="testPacketCoreDP", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_get.py new file mode 100644 index 000000000000..c6c9d955073b --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_data_plane_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_data_planes.get( + resource_group_name="rg1", + packet_core_control_plane_name="testPacketCoreCP", + packet_core_data_plane_name="testPacketCoreDP", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_list_by_packet_core_control_plane.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_list_by_packet_core_control_plane.py new file mode 100644 index 000000000000..037ee1a5cb26 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_list_by_packet_core_control_plane.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_data_plane_list_by_packet_core_control_plane.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_data_planes.list_by_packet_core_control_plane( + resource_group_name="rg1", + packet_core_control_plane_name="testPacketCoreCP", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneListByPacketCoreControlPlane.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_update_tags.py new file mode 100644 index 000000000000..8c012dfc7ede --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_data_plane_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python packet_core_data_plane_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.packet_core_data_planes.update_tags( + resource_group_name="rg1", + packet_core_control_plane_name="testPacketCoreCP", + packet_core_data_plane_name="testPacketCoreDP", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/PacketCoreDataPlaneUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_create.py new file mode 100644 index 000000000000..e5fe7d95ee6b --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_create.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python service_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.services.begin_create_or_update( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + service_name="TestService", + parameters={ + "location": "eastus", + "properties": { + "pccRules": [ + { + "ruleName": "default-rule", + "rulePrecedence": 255, + "ruleQosPolicy": { + "5qi": 9, + "allocationAndRetentionPriorityLevel": 9, + "maximumBitRate": {"downlink": "1 Gbps", "uplink": "500 Mbps"}, + "preemptionCapability": "NotPreempt", + "preemptionVulnerability": "Preemptable", + }, + "serviceDataFlowTemplates": [ + { + "direction": "Uplink", + "ports": [], + "protocol": ["ip"], + "remoteIpList": ["10.3.4.0/24"], + "templateName": "IP-to-server", + } + ], + "trafficControl": "Enabled", + } + ], + "servicePrecedence": 255, + "serviceQosPolicy": { + "5qi": 9, + "allocationAndRetentionPriorityLevel": 9, + "maximumBitRate": {"downlink": "1 Gbps", "uplink": "500 Mbps"}, + "preemptionCapability": "NotPreempt", + "preemptionVulnerability": "Preemptable", + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_delete.py new file mode 100644 index 000000000000..1fa765a1d710 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python service_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.services.begin_delete( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + service_name="TestService", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_get.py new file mode 100644 index 000000000000..3c015e6db02f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python service_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.services.get( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + service_name="TestService", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_list_by_mobile_network.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_list_by_mobile_network.py new file mode 100644 index 000000000000..3965a3e41ca3 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_list_by_mobile_network.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python service_list_by_mobile_network.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.services.list_by_mobile_network( + resource_group_name="testResourceGroupName", + mobile_network_name="testMobileNetwork", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceListByMobileNetwork.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_update_tags.py new file mode 100644 index 000000000000..3c7c459d932a --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/service_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python service_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.services.update_tags( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + service_name="TestService", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/ServiceUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_delete.py new file mode 100644 index 000000000000..2f76a3805a54 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_bulk_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim.begin_bulk_delete( + resource_group_name="testResourceGroupName", + sim_group_name="testSimGroup", + parameters={"sims": ["testSim", "testSim2"]}, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload.py new file mode 100644 index 000000000000..299d046dc50e --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_bulk_upload.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim.begin_bulk_upload( + resource_group_name="rg1", + sim_group_name="testSimGroup", + parameters={ + "sims": [ + { + "name": "testSim", + "properties": { + "authenticationKey": "00000000000000000000000000000000", + "deviceType": "Video camera", + "integratedCircuitCardIdentifier": "8900000000000000000", + "internationalMobileSubscriberIdentity": "00000", + "operatorKeyCode": "00000000000000000000000000000000", + "simPolicy": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy" + }, + "staticIpConfiguration": [ + { + "attachedDataNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork" + }, + "slice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice" + }, + "staticIp": {"ipv4Address": "2.4.0.1"}, + } + ], + }, + }, + { + "name": "testSim2", + "properties": { + "authenticationKey": "00000000000000000000000000000000", + "deviceType": "Video camera", + "integratedCircuitCardIdentifier": "8900000000000000001", + "internationalMobileSubscriberIdentity": "00000", + "operatorKeyCode": "00000000000000000000000000000000", + "simPolicy": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy" + }, + "staticIpConfiguration": [ + { + "attachedDataNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork" + }, + "slice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice" + }, + "staticIp": {"ipv4Address": "2.4.0.2"}, + } + ], + }, + }, + ] + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkUpload.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload_encrypted.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload_encrypted.py new file mode 100644 index 000000000000..f5304c45a0ea --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload_encrypted.py @@ -0,0 +1,96 @@ +# 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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_bulk_upload_encrypted.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim.begin_bulk_upload_encrypted( + resource_group_name="rg1", + sim_group_name="testSimGroup", + parameters={ + "azureKeyIdentifier": 1, + "encryptedTransportKey": "ABC123", + "signedTransportKey": "ABC123", + "sims": [ + { + "name": "testSim", + "properties": { + "deviceType": "Video camera", + "encryptedCredentials": "ABC123", + "integratedCircuitCardIdentifier": "8900000000000000000", + "internationalMobileSubscriberIdentity": "00000", + "simPolicy": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy" + }, + "staticIpConfiguration": [ + { + "attachedDataNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork" + }, + "slice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice" + }, + "staticIp": {"ipv4Address": "2.4.0.1"}, + } + ], + }, + }, + { + "name": "testSim2", + "properties": { + "deviceType": "Video camera", + "encryptedCredentials": "ABC123", + "integratedCircuitCardIdentifier": "8900000000000000001", + "internationalMobileSubscriberIdentity": "00000", + "simPolicy": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy" + }, + "staticIpConfiguration": [ + { + "attachedDataNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork" + }, + "slice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice" + }, + "staticIp": {"ipv4Address": "2.4.0.2"}, + } + ], + }, + }, + ], + "vendorKeyFingerprint": "ABC123", + "version": 1, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimBulkUploadEncrypted.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_create.py new file mode 100644 index 000000000000..345237253e56 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_create.py @@ -0,0 +1,65 @@ +# 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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sims.begin_create_or_update( + resource_group_name="rg1", + sim_group_name="testSimGroup", + sim_name="testSim", + parameters={ + "properties": { + "authenticationKey": "00000000000000000000000000000000", + "deviceType": "Video camera", + "integratedCircuitCardIdentifier": "8900000000000000000", + "internationalMobileSubscriberIdentity": "00000", + "operatorKeyCode": "00000000000000000000000000000000", + "simPolicy": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy" + }, + "staticIpConfiguration": [ + { + "attachedDataNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork" + }, + "slice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice" + }, + "staticIp": {"ipv4Address": "2.4.0.1"}, + } + ], + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_delete.py new file mode 100644 index 000000000000..9e895f599b9b --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sims.begin_delete( + resource_group_name="testResourceGroupName", + sim_group_name="testSimGroup", + sim_name="testSim", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_get.py new file mode 100644 index 000000000000..cbc5fd9f2de9 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sims.get( + resource_group_name="testResourceGroupName", + sim_group_name="testSimGroup", + sim_name="testSimName", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_create.py new file mode 100644 index 000000000000..7e619f707652 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_create.py @@ -0,0 +1,56 @@ +# 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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_group_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_groups.begin_create_or_update( + resource_group_name="rg1", + sim_group_name="testSimGroup", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity": {} + }, + }, + "location": "eastus", + "properties": { + "encryptionKey": {"keyUrl": "https://contosovault.vault.azure.net/keys/azureKey"}, + "mobileNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork" + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_delete.py new file mode 100644 index 000000000000..55ad0a0a704b --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_group_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_groups.begin_delete( + resource_group_name="testResourceGroupName", + sim_group_name="testSimGroup", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_get.py new file mode 100644 index 000000000000..bb637cd3a671 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_get.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_group_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_groups.get( + resource_group_name="testResourceGroupName", + sim_group_name="testSimGroupName", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_list_by_resource_group.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_list_by_resource_group.py new file mode 100644 index 000000000000..96d8136c5eec --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_list_by_resource_group.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_group_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_groups.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_list_by_subscription.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_list_by_subscription.py new file mode 100644 index 000000000000..8e1f4763dae3 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_group_list_by_subscription.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_groups.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_update_tags.py new file mode 100644 index 000000000000..40f8bf095002 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_group_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_group_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_groups.update_tags( + resource_group_name="rg1", + sim_group_name="testSimGroup", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimGroupUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_list_by_sim_group.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_list_by_sim_group.py new file mode 100644 index 000000000000..abdb57da0a59 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_list_by_sim_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_list_by_sim_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sims.list_by_group( + resource_group_name="rg1", + sim_group_name="testSimGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimListBySimGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_create.py new file mode 100644 index 000000000000..71f3886de1ba --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_create.py @@ -0,0 +1,82 @@ +# 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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_policy_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_policies.begin_create_or_update( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + sim_policy_name="testPolicy", + parameters={ + "location": "eastus", + "properties": { + "defaultSlice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice" + }, + "registrationTimer": 3240, + "sliceConfigurations": [ + { + "dataNetworkConfigurations": [ + { + "5qi": 9, + "additionalAllowedSessionTypes": [], + "allocationAndRetentionPriorityLevel": 9, + "allowedServices": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/testService" + } + ], + "dataNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork" + }, + "defaultSessionType": "IPv4", + "maximumNumberOfBufferedPackets": 200, + "preemptionCapability": "NotPreempt", + "preemptionVulnerability": "Preemptable", + "sessionAmbr": {"downlink": "1 Gbps", "uplink": "500 Mbps"}, + } + ], + "defaultDataNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork" + }, + "slice": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice" + }, + } + ], + "ueAmbr": {"downlink": "1 Gbps", "uplink": "500 Mbps"}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_delete.py new file mode 100644 index 000000000000..d87257423709 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_policy_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_policies.begin_delete( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + sim_policy_name="testPolicy", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_get.py new file mode 100644 index 000000000000..97cee6e50aa6 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_policy_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_policies.get( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + sim_policy_name="testPolicy", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_list_by_mobile_network.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_list_by_mobile_network.py new file mode 100644 index 000000000000..a3fe709667ac --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_list_by_mobile_network.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_policy_list_by_mobile_network.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_policies.list_by_mobile_network( + resource_group_name="testResourceGroupName", + mobile_network_name="testMobileNetwork", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyListByMobileNetwork.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_update_tags.py new file mode 100644 index 000000000000..552ddc577f58 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_policy_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python sim_policy_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sim_policies.update_tags( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + sim_policy_name="testPolicy", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SimPolicyUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_create.py new file mode 100644 index 000000000000..9225c8bb9781 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_create.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python site_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sites.begin_create_or_update( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + site_name="testSite", + parameters={"location": "testLocation", "properties": {}}, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_delete.py new file mode 100644 index 000000000000..84743439a6db --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python site_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sites.begin_delete( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + site_name="testSite", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_get.py new file mode 100644 index 000000000000..c47cea02a6cd --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python site_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sites.get( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + site_name="testSite", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_list_by_mobile_network.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_list_by_mobile_network.py new file mode 100644 index 000000000000..1dd0d09264e2 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_list_by_mobile_network.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python site_list_by_mobile_network.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sites.list_by_mobile_network( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteListByMobileNetwork.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_update_tags.py new file mode 100644 index 000000000000..e7d084542fe3 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/site_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python site_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.sites.update_tags( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + site_name="testSite", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SiteUpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_create.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_create.py new file mode 100644 index 000000000000..1bda0f7042b7 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_create.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python slice_create.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.slices.begin_create_or_update( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + slice_name="testSlice", + parameters={ + "location": "eastus", + "properties": {"description": "myFavouriteSlice", "snssai": {"sd": "1abcde", "sst": 1}}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_delete.py new file mode 100644 index 000000000000..85e6ddd36dd8 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_delete.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python slice_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.slices.begin_delete( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + slice_name="testSlice", + ).result() + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_get.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_get.py new file mode 100644 index 000000000000..69703bf26e04 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python slice_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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.slices.get( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + slice_name="testSlice", + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_list_by_mobile_network.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_list_by_mobile_network.py new file mode 100644 index 000000000000..f80d0ed97de1 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_list_by_mobile_network.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python slice_list_by_mobile_network.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.slices.list_by_mobile_network( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceListByMobileNetwork.json +if __name__ == "__main__": + main() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_update_tags.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_update_tags.py new file mode 100644 index 000000000000..dcdc1e6ae0c5 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/slice_update_tags.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.mobilenetwork import MobileNetworkManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mobilenetwork +# USAGE + python slice_update_tags.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 = MobileNetworkManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.slices.update_tags( + resource_group_name="rg1", + mobile_network_name="testMobileNetwork", + slice_name="testSlice", + parameters={"tags": {"tag1": "value1", "tag2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2022-11-01/examples/SliceUpdateTags.json +if __name__ == "__main__": + main()