From bf42eb78ac6a21751fffa44b06655fd34ed7e352 Mon Sep 17 00:00:00 2001 From: Azure CLI Bot Date: Mon, 28 Feb 2022 12:36:28 +0800 Subject: [PATCH] [AutoRelease] t2-mobilenetwork-2022-02-20-80861(Do not merge) (#23151) * code and test * Update CHANGELOG.md Co-authored-by: PythonSdkPipelines Co-authored-by: Yuchao Yan --- .../azure-mgmt-mobilenetwork/CHANGELOG.md | 5 + .../azure-mgmt-mobilenetwork/LICENSE | 21 + .../azure-mgmt-mobilenetwork/MANIFEST.in | 6 + .../azure-mgmt-mobilenetwork/README.md | 30 + .../azure-mgmt-mobilenetwork/_meta.json | 11 + .../azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/mobilenetwork/__init__.py | 18 + .../mgmt/mobilenetwork/_configuration.py | 68 + .../azure/mgmt/mobilenetwork/_metadata.json | 112 + .../_mobile_network_management_client.py | 126 + .../azure/mgmt/mobilenetwork/_patch.py | 31 + .../azure/mgmt/mobilenetwork/_vendor.py | 27 + .../azure/mgmt/mobilenetwork/_version.py | 9 + .../azure/mgmt/mobilenetwork/aio/__init__.py | 15 + .../mgmt/mobilenetwork/aio/_configuration.py | 67 + .../aio/_mobile_network_management_client.py | 124 + .../azure/mgmt/mobilenetwork/aio/_patch.py | 31 + .../mobilenetwork/aio/operations/__init__.py | 33 + .../_attached_data_networks_operations.py | 499 +++ .../operations/_data_networks_operations.py | 475 +++ .../operations/_mobile_networks_operations.py | 624 +++ .../aio/operations/_operations.py | 110 + .../_packet_core_control_planes_operations.py | 516 +++ .../_packet_core_data_planes_operations.py | 475 +++ .../aio/operations/_services_operations.py | 476 +++ .../operations/_sim_policies_operations.py | 472 +++ .../aio/operations/_sims_operations.py | 511 +++ .../aio/operations/_sites_operations.py | 471 +++ .../aio/operations/_slices_operations.py | 471 +++ .../mgmt/mobilenetwork/models/__init__.py | 145 + ..._mobile_network_management_client_enums.py | 90 + .../mgmt/mobilenetwork/models/_models_py3.py | 3424 +++++++++++++++++ .../mgmt/mobilenetwork/operations/__init__.py | 33 + .../_attached_data_networks_operations.py | 712 ++++ .../operations/_data_networks_operations.py | 677 ++++ .../operations/_mobile_networks_operations.py | 881 +++++ .../mobilenetwork/operations/_operations.py | 135 + .../_packet_core_control_planes_operations.py | 740 ++++ .../_packet_core_data_planes_operations.py | 678 ++++ .../operations/_services_operations.py | 678 ++++ .../operations/_sim_policies_operations.py | 674 ++++ .../operations/_sims_operations.py | 733 ++++ .../operations/_sites_operations.py | 673 ++++ .../operations/_slices_operations.py | 673 ++++ .../azure/mgmt/mobilenetwork/py.typed | 1 + .../sdk_packaging.toml | 9 + .../azure-mgmt-mobilenetwork/setup.py | 73 + sdk/mobilenetwork/ci.yml | 33 + shared_requirements.txt | 2 + 50 files changed, 16900 insertions(+) create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/CHANGELOG.md create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/LICENSE create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/MANIFEST.in create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/README.md create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/__init__.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/__init__.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_configuration.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_metadata.json create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_patch.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/__init__.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_configuration.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_patch.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_attached_data_networks_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_data_networks_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_mobile_networks_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_data_planes_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_services_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_policies_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sites_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_slices_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/__init__.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_mobile_network_management_client_enums.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_models_py3.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_attached_data_networks_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_data_networks_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_mobile_networks_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_data_planes_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_services_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_policies_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sites_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_slices_operations.py create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/py.typed create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/sdk_packaging.toml create mode 100644 sdk/mobilenetwork/azure-mgmt-mobilenetwork/setup.py create mode 100644 sdk/mobilenetwork/ci.yml diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/CHANGELOG.md b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/CHANGELOG.md new file mode 100644 index 000000000000..a8857230ba51 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1(2022-02-28) + +* Initial Release diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/LICENSE b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +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. diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/MANIFEST.in b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/README.md b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/README.md new file mode 100644 index 000000000000..5d6616cfc257 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure Mobilenetwork Management Client Library. +This package has been tested with Python 3.7+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [Mobilenetwork Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-mobilenetwork%2FREADME.png) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json new file mode 100644 index 000000000000..6534dd1db308 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "d2d48558c0c8f2828c7368e66bcdcabf3a10bafb", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/mobilenetwork/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/mobilenetwork/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py new file mode 100644 index 000000000000..b74e472ac079 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/__init__.py @@ -0,0 +1,18 @@ +# 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 ._mobile_network_management_client import MobileNetworkManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['MobileNetworkManagementClient'] + +# `._patch.py` 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 +from ._patch import patch_sdk +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 new file mode 100644 index 000000000000..6fb2d27ae1ce --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_configuration.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class MobileNetworkManagementClientConfiguration(Configuration): + """Configuration for MobileNetworkManagementClient. + + 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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MobileNetworkManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2022-01-01-preview" + 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') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_metadata.json b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_metadata.json new file mode 100644 index 000000000000..30820d8b4209 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_metadata.json @@ -0,0 +1,112 @@ +{ + "chosen_version": "2022-01-01-preview", + "total_api_version_list": ["2022-01-01-preview"], + "client": { + "name": "MobileNetworkManagementClient", + "filename": "_mobile_network_management_client", + "description": "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.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MobileNetworkManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MobileNetworkManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "attached_data_networks": "AttachedDataNetworksOperations", + "data_networks": "DataNetworksOperations", + "mobile_networks": "MobileNetworksOperations", + "sites": "SitesOperations", + "sims": "SimsOperations", + "operations": "Operations", + "packet_core_control_planes": "PacketCoreControlPlanesOperations", + "packet_core_data_planes": "PacketCoreDataPlanesOperations", + "services": "ServicesOperations", + "sim_policies": "SimPoliciesOperations", + "slices": "SlicesOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..02cbde2d71b3 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py @@ -0,0 +1,126 @@ +# 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 copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import MobileNetworkManagementClientConfiguration +from .operations import AttachedDataNetworksOperations, DataNetworksOperations, MobileNetworksOperations, Operations, PacketCoreControlPlanesOperations, PacketCoreDataPlanesOperations, ServicesOperations, SimPoliciesOperations, SimsOperations, SitesOperations, SlicesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class MobileNetworkManagementClient: + """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. + + :ivar attached_data_networks: AttachedDataNetworksOperations operations + :vartype attached_data_networks: + mobile_network_management_client.operations.AttachedDataNetworksOperations + :ivar data_networks: DataNetworksOperations operations + :vartype data_networks: mobile_network_management_client.operations.DataNetworksOperations + :ivar mobile_networks: MobileNetworksOperations operations + :vartype mobile_networks: mobile_network_management_client.operations.MobileNetworksOperations + :ivar sites: SitesOperations operations + :vartype sites: mobile_network_management_client.operations.SitesOperations + :ivar sims: SimsOperations operations + :vartype sims: mobile_network_management_client.operations.SimsOperations + :ivar operations: Operations operations + :vartype operations: mobile_network_management_client.operations.Operations + :ivar packet_core_control_planes: PacketCoreControlPlanesOperations operations + :vartype packet_core_control_planes: + mobile_network_management_client.operations.PacketCoreControlPlanesOperations + :ivar packet_core_data_planes: PacketCoreDataPlanesOperations operations + :vartype packet_core_data_planes: + mobile_network_management_client.operations.PacketCoreDataPlanesOperations + :ivar services: ServicesOperations operations + :vartype services: mobile_network_management_client.operations.ServicesOperations + :ivar sim_policies: SimPoliciesOperations operations + :vartype sim_policies: mobile_network_management_client.operations.SimPoliciesOperations + :ivar slices: SlicesOperations operations + :vartype slices: mobile_network_management_client.operations.SlicesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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)} + 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.sims = SimsOperations(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_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, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> MobileNetworkManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> 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 new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# 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 diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +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 new file mode 100644 index 000000000000..558e282f2dcd --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/__init__.py @@ -0,0 +1,15 @@ +# 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 ._mobile_network_management_client import MobileNetworkManagementClient +__all__ = ['MobileNetworkManagementClient'] + +# `._patch.py` 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 +from ._patch import patch_sdk +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 new file mode 100644 index 000000000000..fc6c61707cac --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MobileNetworkManagementClientConfiguration(Configuration): + """Configuration for MobileNetworkManagementClient. + + 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MobileNetworkManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2022-01-01-preview" + 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') + if self.credential and not self.authentication_policy: + 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 new file mode 100644 index 000000000000..8d3dc266e180 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py @@ -0,0 +1,124 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import MobileNetworkManagementClientConfiguration +from .operations import AttachedDataNetworksOperations, DataNetworksOperations, MobileNetworksOperations, Operations, PacketCoreControlPlanesOperations, PacketCoreDataPlanesOperations, ServicesOperations, SimPoliciesOperations, SimsOperations, SitesOperations, SlicesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class MobileNetworkManagementClient: + """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. + + :ivar attached_data_networks: AttachedDataNetworksOperations operations + :vartype attached_data_networks: + mobile_network_management_client.aio.operations.AttachedDataNetworksOperations + :ivar data_networks: DataNetworksOperations operations + :vartype data_networks: mobile_network_management_client.aio.operations.DataNetworksOperations + :ivar mobile_networks: MobileNetworksOperations operations + :vartype mobile_networks: + mobile_network_management_client.aio.operations.MobileNetworksOperations + :ivar sites: SitesOperations operations + :vartype sites: mobile_network_management_client.aio.operations.SitesOperations + :ivar sims: SimsOperations operations + :vartype sims: mobile_network_management_client.aio.operations.SimsOperations + :ivar operations: Operations operations + :vartype operations: mobile_network_management_client.aio.operations.Operations + :ivar packet_core_control_planes: PacketCoreControlPlanesOperations operations + :vartype packet_core_control_planes: + mobile_network_management_client.aio.operations.PacketCoreControlPlanesOperations + :ivar packet_core_data_planes: PacketCoreDataPlanesOperations operations + :vartype packet_core_data_planes: + mobile_network_management_client.aio.operations.PacketCoreDataPlanesOperations + :ivar services: ServicesOperations operations + :vartype services: mobile_network_management_client.aio.operations.ServicesOperations + :ivar sim_policies: SimPoliciesOperations operations + :vartype sim_policies: mobile_network_management_client.aio.operations.SimPoliciesOperations + :ivar slices: SlicesOperations operations + :vartype slices: mobile_network_management_client.aio.operations.SlicesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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)} + 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.sims = SimsOperations(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_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]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MobileNetworkManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) 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 new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# 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 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 new file mode 100644 index 000000000000..349366a76107 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py @@ -0,0 +1,33 @@ +# 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 ._attached_data_networks_operations import AttachedDataNetworksOperations +from ._data_networks_operations import DataNetworksOperations +from ._mobile_networks_operations import MobileNetworksOperations +from ._sites_operations import SitesOperations +from ._sims_operations import SimsOperations +from ._operations import Operations +from ._packet_core_control_planes_operations import PacketCoreControlPlanesOperations +from ._packet_core_data_planes_operations import PacketCoreDataPlanesOperations +from ._services_operations import ServicesOperations +from ._sim_policies_operations import SimPoliciesOperations +from ._slices_operations import SlicesOperations + +__all__ = [ + 'AttachedDataNetworksOperations', + 'DataNetworksOperations', + 'MobileNetworksOperations', + 'SitesOperations', + 'SimsOperations', + 'Operations', + 'PacketCoreControlPlanesOperations', + 'PacketCoreDataPlanesOperations', + 'ServicesOperations', + 'SimPoliciesOperations', + 'SlicesOperations', +] 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 new file mode 100644 index 000000000000..b4d751f8a30c --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_attached_data_networks_operations.py @@ -0,0 +1,499 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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._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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AttachedDataNetworksOperations: + """AttachedDataNetworksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_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, + attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + 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 + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified attached data network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_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, + attached_data_network_name=attached_data_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + **kwargs: Any + ) -> "_models.AttachedDataNetwork": + """Gets information about the specified attached data network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :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) + :rtype: ~mobile_network_management_client.models.AttachedDataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: "_models.AttachedDataNetwork", + **kwargs: Any + ) -> "_models.AttachedDataNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AttachedDataNetwork') + + request = build_create_or_update_request_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, + attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}'} # type: ignore + + + @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: "_models.AttachedDataNetwork", + **kwargs: Any + ) -> AsyncLROPoller["_models.AttachedDataNetwork"]: + """Creates or updates an attached data network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :type attached_data_network_name: str + :param parameters: Parameters supplied to the create or update attached data network operation. + :type parameters: ~mobile_network_management_client.models.AttachedDataNetwork + :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[~mobile_network_management_client.models.AttachedDataNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + 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._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, + attached_data_network_name=attached_data_network_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}'} # type: ignore + + @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: "_models.TagsObject", + **kwargs: Any + ) -> "_models.AttachedDataNetwork": + """Updates an attached data network update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :type attached_data_network_name: str + :param parameters: Parameters supplied to update attached data network tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AttachedDataNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.AttachedDataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_packet_core_data_plane( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.AttachedDataNetworkListResult"]: + """Gets all the data networks associated with a packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :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.async_paging.AsyncItemPaged[~mobile_network_management_client.models.AttachedDataNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_packet_core_data_plane_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, + template_url=self.list_by_packet_core_data_plane.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_packet_core_data_plane_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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + 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 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 new file mode 100644 index 000000000000..a0ce110f9fb3 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_data_networks_operations.py @@ -0,0 +1,475 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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._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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DataNetworksOperations: + """DataNetworksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified mobile network dataNetwork. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + **kwargs: Any + ) -> "_models.DataNetwork": + """Gets information about the specified mobile network dataNetwork. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :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) + :rtype: ~mobile_network_management_client.models.DataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: "_models.DataNetwork", + **kwargs: Any + ) -> "_models.DataNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DataNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('DataNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DataNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: "_models.DataNetwork", + **kwargs: Any + ) -> AsyncLROPoller["_models.DataNetwork"]: + """Creates or updates a mobile network dataNetwork. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :type data_network_name: str + :param parameters: Parameters supplied to the create or update mobile network dataNetwork + operation. + :type parameters: ~mobile_network_management_client.models.DataNetwork + :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[~mobile_network_management_client.models.DataNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DataNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.DataNetwork": + """Update data network tags. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :type data_network_name: str + :param parameters: Parameters supplied to update data network tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.DataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.DataNetworkListResult"]: + """Lists all dataNetworks in the 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 + :return: An iterator like instance of either DataNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.DataNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks'} # type: ignore 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 new file mode 100644 index 000000000000..8c4e4b8f638c --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_mobile_networks_operations.py @@ -0,0 +1,624 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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._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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MobileNetworksOperations: + """MobileNetworksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + + @distributed_trace_async + 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + @distributed_trace_async + 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. + :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 + :return: MobileNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.MobileNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: "_models.MobileNetwork", + **kwargs: Any + ) -> "_models.MobileNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MobileNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('MobileNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('MobileNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: "_models.MobileNetwork", + **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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param parameters: Parameters supplied to the create or update mobile network operation. + :type parameters: ~mobile_network_management_client.models.MobileNetwork + :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[~mobile_network_management_client.models.MobileNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('MobileNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.MobileNetwork": + """Updates a mobile network update tags. + + :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 + :param parameters: Parameters supplied to update mobile network tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MobileNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.MobileNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.MobileNetworkListResult"]: + """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[~mobile_network_management_client.models.MobileNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.MobileNetworkListResult"]: + """Lists all the mobile networks in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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[~mobile_network_management_client.models.MobileNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + 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": + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimIdListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self._list_sim_ids_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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"]: + """List sim ids under 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[~mobile_network_management_client.models.SimIdListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimIdListResult"] + 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( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('SimIdListResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + 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 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 new file mode 100644 index 000000000000..8a8bc29cc957 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_operations.py @@ -0,0 +1,110 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationList"]: + """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[~mobile_network_management_client.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.MobileNetwork/operations'} # type: ignore 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 new file mode 100644 index 000000000000..4cb1273d77f8 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py @@ -0,0 +1,516 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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_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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PacketCoreControlPlanesOperations: + """PacketCoreControlPlanesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + + @distributed_trace_async + 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. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + @distributed_trace_async + async def get( + 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. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :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) + :rtype: ~mobile_network_management_client.models.PacketCoreControlPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: "_models.PacketCoreControlPlane", + **kwargs: Any + ) -> "_models.PacketCoreControlPlane": + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PacketCoreControlPlane') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: "_models.PacketCoreControlPlane", + **kwargs: Any + ) -> AsyncLROPoller["_models.PacketCoreControlPlane"]: + """Creates or updates a PacketCoreControlPlane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the create or update packet core control plane + operation. + :type parameters: ~mobile_network_management_client.models.PacketCoreControlPlane + :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[~mobile_network_management_client.models.PacketCoreControlPlane] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.PacketCoreControlPlane": + """Updates a PacketCoreControlPlane update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to update PacketCoreControlPlane tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PacketCoreControlPlane, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.PacketCoreControlPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.PacketCoreControlPlaneListResult"]: + """Lists all the packetCoreControlPlanes 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 + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.PacketCoreControlPlaneListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlaneListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PacketCoreControlPlaneListResult"]: + """Lists all the packetCoreControlPlanes in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.PacketCoreControlPlaneListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlaneListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes'} # type: ignore 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 new file mode 100644 index 000000000000..6d49e7984e2d --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_data_planes_operations.py @@ -0,0 +1,475 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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_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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PacketCoreDataPlanesOperations: + """PacketCoreDataPlanesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_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, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> "_models.PacketCoreDataPlane": + """Gets information about the specified packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :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) + :rtype: ~mobile_network_management_client.models.PacketCoreDataPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + 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", + **kwargs: Any + ) -> "_models.PacketCoreDataPlane": + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PacketCoreDataPlane') + + request = build_create_or_update_request_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, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + + @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: "_models.PacketCoreDataPlane", + **kwargs: Any + ) -> AsyncLROPoller["_models.PacketCoreDataPlane"]: + """Creates or updates a PacketCoreDataPlane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to the create or update packet core data plane + operation. + :type parameters: ~mobile_network_management_client.models.PacketCoreDataPlane + :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[~mobile_network_management_client.models.PacketCoreDataPlane] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + 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._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, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + @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: "_models.TagsObject", + **kwargs: Any + ) -> "_models.PacketCoreDataPlane": + """Updates a PacketCoreDataPlane update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to update PacketCoreDataPlane tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PacketCoreDataPlane, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.PacketCoreDataPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @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"]: + """Lists all the packetCoreDataPlanes associated with a packetCoreControlPlane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :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.async_paging.AsyncItemPaged[~mobile_network_management_client.models.PacketCoreDataPlaneListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlaneListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_packet_core_control_plane.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + 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 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 new file mode 100644 index 000000000000..d10bacb30dcc --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_services_operations.py @@ -0,0 +1,476 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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._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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServicesOperations: + """ServicesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + + @distributed_trace_async + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :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``. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + @distributed_trace_async + async def get( + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :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``. + :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) + :rtype: ~mobile_network_management_client.models.Service + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: "_models.Service", + **kwargs: Any + ) -> "_models.Service": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Service') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Service', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Service', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: "_models.Service", + **kwargs: Any + ) -> AsyncLROPoller["_models.Service"]: + """Creates or updates a Service. + + :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 + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. + :type service_name: str + :param parameters: Parameters supplied to the create or update service operation. + :type parameters: ~mobile_network_management_client.models.Service + :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[~mobile_network_management_client.models.Service] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Service', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Service": + """Update service tags. + + :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 + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. + :type service_name: str + :param parameters: Parameters supplied to update service tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Service, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Service + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ServiceListResult"]: + """Gets all the services 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 + :return: An iterator like instance of either ServiceListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.ServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services'} # type: ignore 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 new file mode 100644 index 000000000000..ad5a60a34535 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_policies_operations.py @@ -0,0 +1,472 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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_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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SimPoliciesOperations: + """SimPoliciesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + + @distributed_trace_async + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + @distributed_trace_async + async def get( + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. + :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) + :rtype: ~mobile_network_management_client.models.SimPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: "_models.SimPolicy", + **kwargs: Any + ) -> "_models.SimPolicy": + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SimPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('SimPolicy', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SimPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: "_models.SimPolicy", + **kwargs: Any + ) -> AsyncLROPoller["_models.SimPolicy"]: + """Creates or updates a SimPolicy. + + :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 + :param sim_policy_name: The name of the SIM policy. + :type sim_policy_name: str + :param parameters: Parameters supplied to the create or update sim policy operation. + :type parameters: ~mobile_network_management_client.models.SimPolicy + :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[~mobile_network_management_client.models.SimPolicy] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('SimPolicy', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.SimPolicy": + """Update sim policy tags. + + :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 + :param sim_policy_name: The name of the SIM policy. + :type sim_policy_name: str + :param parameters: Parameters supplied to update Sim Policy tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimPolicy, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.SimPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SimPolicyListResult"]: + """Gets all the simPolicies 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 + :return: An iterator like instance of either SimPolicyListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.SimPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies'} # type: ignore 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 new file mode 100644 index 000000000000..d356f74b9302 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py @@ -0,0 +1,511 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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._sims_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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SimsOperations: + """SimsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + sim_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_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. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + sim_name=sim_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_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. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :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) + :rtype: ~mobile_network_management_client.models.Sim + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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/sims/{simName}'} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + sim_name: str, + parameters: "_models.Sim", + **kwargs: Any + ) -> "_models.Sim": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Sim') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Sim', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Sim', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + sim_name: str, + parameters: "_models.Sim", + **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. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :type sim_name: str + :param parameters: Parameters supplied to the create or update sim operation. + :type parameters: ~mobile_network_management_client.models.Sim + :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[~mobile_network_management_client.models.Sim] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + sim_name=sim_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Sim', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + sim_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Sim": + """Updates a sim update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :type sim_name: str + :param parameters: Parameters supplied to update sim tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Sim, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Sim + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Sim', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.SimListResult"]: + """Gets all the sims 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 SimListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.SimListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/sims'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SimListResult"]: + """Gets all the Sims in a subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 SimListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.SimListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims'} # type: ignore 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 new file mode 100644 index 000000000000..59085ef3ada1 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sites_operations.py @@ -0,0 +1,471 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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._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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SitesOperations: + """SitesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + + @distributed_trace_async + 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. + + :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 + :param site_name: The name of the mobile network site. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + @distributed_trace_async + async 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. + :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) + :rtype: ~mobile_network_management_client.models.Site + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: "_models.Site", + **kwargs: Any + ) -> "_models.Site": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Site') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Site', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Site', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: "_models.Site", + **kwargs: Any + ) -> AsyncLROPoller["_models.Site"]: + """Creates or updates a mobile network site. + + :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 + :param site_name: The name of the mobile network site. + :type site_name: str + :param parameters: Parameters supplied to the create or update mobile network site operation. + :type parameters: ~mobile_network_management_client.models.Site + :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[~mobile_network_management_client.models.Site] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Site', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Site": + """Updates a site update tags. + + :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 + :param site_name: The name of the mobile network site. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Site, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Site + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SiteListResult"]: + """Lists all sites in the 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 + :return: An iterator like instance of either SiteListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.SiteListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SiteListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites'} # type: ignore 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 new file mode 100644 index 000000000000..249cd8573ef4 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_slices_operations.py @@ -0,0 +1,471 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +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._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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SlicesOperations: + """SlicesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified mobile network slice. + + :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 + :param slice_name: The name of the mobile network slice. + :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + **kwargs: Any + ) -> "_models.Slice": + """Gets information about the specified mobile network slice. + + :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 + :param slice_name: The name of the mobile network slice. + :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) + :rtype: ~mobile_network_management_client.models.Slice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: "_models.Slice", + **kwargs: Any + ) -> "_models.Slice": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Slice') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Slice', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Slice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: "_models.Slice", + **kwargs: Any + ) -> AsyncLROPoller["_models.Slice"]: + """Creates or updates a mobile network slice. + + :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 + :param slice_name: The name of the mobile network slice. + :type slice_name: str + :param parameters: Parameters supplied to the create or update mobile network slice operation. + :type parameters: ~mobile_network_management_client.models.Slice + :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[~mobile_network_management_client.models.Slice] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Slice', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Slice": + """Update slice tags. + + :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 + :param slice_name: The name of the mobile network slice. + :type slice_name: str + :param parameters: Parameters supplied to update mobile network slice tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Slice, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Slice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SliceListResult"]: + """Lists all slices in the 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 + :return: An iterator like instance of either SliceListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~mobile_network_management_client.models.SliceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SliceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices'} # type: ignore 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 new file mode 100644 index 000000000000..b46b1518ddd4 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/__init__.py @@ -0,0 +1,145 @@ +# 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 ._models_py3 import Ambr +from ._models_py3 import Arp +from ._models_py3 import AttachedDataNetwork +from ._models_py3 import AttachedDataNetworkListResult +from ._models_py3 import AttachedDataNetworkResourceId +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 ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import InterfaceProperties +from ._models_py3 import MobileNetwork +from ._models_py3 import MobileNetworkListResult +from ._models_py3 import MobileNetworkResourceId +from ._models_py3 import NaptConfiguration +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationList +from ._models_py3 import PacketCoreControlPlane +from ._models_py3 import PacketCoreControlPlaneListResult +from ._models_py3 import PacketCoreDataPlane +from ._models_py3 import PacketCoreDataPlaneListResult +from ._models_py3 import PccRuleConfiguration +from ._models_py3 import PccRuleQosPolicy +from ._models_py3 import PinholeTimeouts +from ._models_py3 import PlmnId +from ._models_py3 import PortRange +from ._models_py3 import PortReuseHoldTimes +from ._models_py3 import QosPolicy +from ._models_py3 import Resource +from ._models_py3 import Service +from ._models_py3 import ServiceDataFlowTemplate +from ._models_py3 import ServiceListResult +from ._models_py3 import ServiceResourceId +from ._models_py3 import Sim +from ._models_py3 import SimIdListResult +from ._models_py3 import SimListResult +from ._models_py3 import SimPolicy +from ._models_py3 import SimPolicyListResult +from ._models_py3 import SimPolicyResourceId +from ._models_py3 import SimStaticIpProperties +from ._models_py3 import SimStaticIpPropertiesStaticIp +from ._models_py3 import Site +from ._models_py3 import SiteListResult +from ._models_py3 import Slice +from ._models_py3 import SliceConfiguration +from ._models_py3 import SliceListResult +from ._models_py3 import SliceResourceId +from ._models_py3 import Snssai +from ._models_py3 import SubResource +from ._models_py3 import TagsObject +from ._models_py3 import TrackedResource + + +from ._mobile_network_management_client_enums import ( + ConfigurationState, + CoreNetworkType, + CreatedByType, + NaptEnabled, + PduSessionType, + PreemptionCapability, + PreemptionVulnerability, + ProvisioningState, + SdfDirection, + TrafficControlPermission, +) + +__all__ = [ + 'Ambr', + 'Arp', + 'AttachedDataNetwork', + 'AttachedDataNetworkListResult', + 'AttachedDataNetworkResourceId', + 'CustomLocationResourceId', + 'DataNetwork', + 'DataNetworkConfiguration', + 'DataNetworkListResult', + 'DataNetworkResourceId', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'InterfaceProperties', + 'MobileNetwork', + 'MobileNetworkListResult', + 'MobileNetworkResourceId', + 'NaptConfiguration', + 'Operation', + 'OperationDisplay', + 'OperationList', + 'PacketCoreControlPlane', + 'PacketCoreControlPlaneListResult', + 'PacketCoreDataPlane', + 'PacketCoreDataPlaneListResult', + 'PccRuleConfiguration', + 'PccRuleQosPolicy', + 'PinholeTimeouts', + 'PlmnId', + 'PortRange', + 'PortReuseHoldTimes', + 'QosPolicy', + 'Resource', + 'Service', + 'ServiceDataFlowTemplate', + 'ServiceListResult', + 'ServiceResourceId', + 'Sim', + 'SimIdListResult', + 'SimListResult', + 'SimPolicy', + 'SimPolicyListResult', + 'SimPolicyResourceId', + 'SimStaticIpProperties', + 'SimStaticIpPropertiesStaticIp', + 'Site', + 'SiteListResult', + 'Slice', + 'SliceConfiguration', + 'SliceListResult', + 'SliceResourceId', + 'Snssai', + 'SubResource', + 'TagsObject', + 'TrackedResource', + 'ConfigurationState', + 'CoreNetworkType', + 'CreatedByType', + 'NaptEnabled', + 'PduSessionType', + 'PreemptionCapability', + 'PreemptionVulnerability', + 'ProvisioningState', + 'SdfDirection', + 'TrafficControlPermission', +] 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 new file mode 100644 index 000000000000..c0e0f2a39738 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_mobile_network_management_client_enums.py @@ -0,0 +1,90 @@ +# 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 enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class ConfigurationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The configuration state of the resource - complete or incomplete. + """ + + INCOMPLETE = "Incomplete" + COMPLETE = "Complete" + +class CoreNetworkType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Core network type. + """ + + FIVE_GC = "5GC" + EPC = "EPC" + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class NaptEnabled(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Whether Network Address and Port Translation is enabled. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class PduSessionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """PDU session type (IPv4/IPv6). + """ + + I_PV4 = "IPv4" + I_PV6 = "IPv6" + +class PreemptionCapability(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Preemption capability. + """ + + NOT_PREEMPT = "NotPreempt" + MAY_PREEMPT = "MayPreempt" + +class PreemptionVulnerability(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Preemption vulnerability. + """ + + NOT_PREEMPTABLE = "NotPreemptable" + PREEMPTABLE = "Preemptable" + +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The current provisioning state. + """ + + UNKNOWN = "Unknown" + SUCCEEDED = "Succeeded" + ACCEPTED = "Accepted" + DELETING = "Deleting" + FAILED = "Failed" + CANCELED = "Canceled" + DELETED = "Deleted" + +class SdfDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Service data flow direction. + """ + + UPLINK = "Uplink" + DOWNLINK = "Downlink" + BIDIRECTIONAL = "Bidirectional" + +class TrafficControlPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Traffic control permission. + """ + + ENABLED = "Enabled" + BLOCKED = "Blocked" 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 new file mode 100644 index 000000000000..a286b6dfb5ac --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/models/_models_py3.py @@ -0,0 +1,3424 @@ +# 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 datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._mobile_network_management_client_enums import * + + +class Ambr(msrest.serialization.Model): + """Aggregate Maximum Bit Rate. + + All required parameters must be populated in order to send to Azure. + + :ivar uplink: Required. Uplink bit rate. + :vartype uplink: str + :ivar downlink: Required. Downlink bit rate. + :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)$'}, + } + + _attribute_map = { + 'uplink': {'key': 'uplink', 'type': 'str'}, + 'downlink': {'key': 'downlink', 'type': 'str'}, + } + + def __init__( + self, + *, + uplink: str, + downlink: str, + **kwargs + ): + """ + :keyword uplink: Required. Uplink bit rate. + :paramtype uplink: str + :keyword downlink: Required. Downlink bit rate. + :paramtype downlink: str + """ + super(Ambr, self).__init__(**kwargs) + self.uplink = uplink + self.downlink = downlink + + +class Arp(msrest.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. + :vartype priority_level: int + :ivar preempt_cap: Required. ARP preemption capability. Possible values include: "NotPreempt", + "MayPreempt". + :vartype preempt_cap: str or ~mobile_network_management_client.models.PreemptionCapability + :ivar preempt_vuln: Required. ARP preemption vulnerability. Possible values include: + "NotPreemptable", "Preemptable". + :vartype preempt_vuln: str or ~mobile_network_management_client.models.PreemptionVulnerability + """ + + _validation = { + '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'}, + } + + def __init__( + self, + *, + priority_level: int, + preempt_cap: Union[str, "PreemptionCapability"], + preempt_vuln: Union[str, "PreemptionVulnerability"], + **kwargs + ): + """ + :keyword priority_level: Required. ARP priority level. + :paramtype priority_level: int + :keyword preempt_cap: Required. ARP preemption capability. Possible values include: + "NotPreempt", "MayPreempt". + :paramtype preempt_cap: str or ~mobile_network_management_client.models.PreemptionCapability + :keyword preempt_vuln: Required. ARP preemption vulnerability. Possible values include: + "NotPreemptable", "Preemptable". + :paramtype preempt_vuln: str or + ~mobile_network_management_client.models.PreemptionVulnerability + """ + super(Arp, self).__init__(**kwargs) + self.priority_level = priority_level + self.preempt_cap = preempt_cap + self.preempt_vuln = preempt_vuln + + +class Resource(msrest.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. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + 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 id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class AttachedDataNetwork(TrackedResource): + """Attached data network resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the attached data network resource. + Possible values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.models.ProvisioningState + :ivar user_plane_data_interface: Required. The user plane interface on the data network. In 5G + networks this is called as N6 interface whereas in 4G networks this is called as SGi interface. + :vartype user_plane_data_interface: + ~mobile_network_management_client.models.InterfaceProperties + :ivar napt_configuration: The Network Address and Port Translation configuration. + If not specified the attached data network uses a default NAPT configuration with NAPT + enabled. + :vartype napt_configuration: ~mobile_network_management_client.models.NaptConfiguration + :ivar user_equipment_address_pool_prefix: The user equipment address pool prefixes for the + attached data network that are dynamically assigned by the core to UEs when they set up a PDU + session. + At least one of userEquipmentAddressPoolPrefix and userEquipmentStaticAddressPoolPrefix must + be defined. If both are defined then they must be the same size. + :vartype user_equipment_address_pool_prefix: list[str] + :ivar user_equipment_static_address_pool_prefix: The user equipment address pool prefixes for + the attached data network that are statically assigned by the core to UEs when they set up a + PDU session. + The mapping of static IP to sim is configured in staticIpConfiguration on the sim resource. + At least one of userEquipmentAddressPoolPrefix and userEquipmentStaticAddressPoolPrefix must + be defined. If both are defined then they must be the same size. + :vartype user_equipment_static_address_pool_prefix: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'user_plane_data_interface': {'required': 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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'user_plane_data_interface': {'key': 'properties.userPlaneDataInterface', 'type': 'InterfaceProperties'}, + '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__( + self, + *, + location: str, + user_plane_data_interface: "InterfaceProperties", + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + napt_configuration: Optional["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. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword user_plane_data_interface: Required. The user plane interface on the data network. In + 5G networks this is called as N6 interface whereas in 4G networks this is called as SGi + interface. + :paramtype user_plane_data_interface: + ~mobile_network_management_client.models.InterfaceProperties + :keyword napt_configuration: The Network Address and Port Translation configuration. + If not specified the attached data network uses a default NAPT configuration with NAPT + enabled. + :paramtype napt_configuration: ~mobile_network_management_client.models.NaptConfiguration + :keyword user_equipment_address_pool_prefix: The user equipment address pool prefixes for the + attached data network that are dynamically assigned by the core to UEs when they set up a PDU + session. + At least one of userEquipmentAddressPoolPrefix and userEquipmentStaticAddressPoolPrefix must + be defined. If both are defined then they must be the same size. + :paramtype user_equipment_address_pool_prefix: list[str] + :keyword user_equipment_static_address_pool_prefix: The user equipment address pool prefixes + for the attached data network that are statically assigned by the core to UEs when they set up + a PDU session. + The mapping of static IP to sim is configured in staticIpConfiguration on the sim resource. + At least one of userEquipmentAddressPoolPrefix and userEquipmentStaticAddressPoolPrefix must + be defined. If both are defined then they must be the same size. + :paramtype user_equipment_static_address_pool_prefix: list[str] + """ + super(AttachedDataNetwork, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.user_plane_data_interface = user_plane_data_interface + self.napt_configuration = napt_configuration + self.user_equipment_address_pool_prefix = user_equipment_address_pool_prefix + self.user_equipment_static_address_pool_prefix = user_equipment_static_address_pool_prefix + + +class AttachedDataNetworkListResult(msrest.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. + + :ivar value: A list of data networks in a resource group. + :vartype value: list[~mobile_network_management_client.models.AttachedDataNetwork] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AttachedDataNetwork]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AttachedDataNetwork"]] = None, + **kwargs + ): + """ + :keyword value: A list of data networks in a resource group. + :paramtype value: list[~mobile_network_management_client.models.AttachedDataNetwork] + """ + super(AttachedDataNetworkListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class AttachedDataNetworkResourceId(msrest.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. + :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]/[^/?#]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Attached Data Network resource ID. + :paramtype id: str + """ + super(AttachedDataNetworkResourceId, self).__init__(**kwargs) + self.id = id + + +class CustomLocationResourceId(msrest.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. + :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]/[^/?#]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Azure ARC custom location resource ID. + :paramtype id: str + """ + super(CustomLocationResourceId, self).__init__(**kwargs) + self.id = id + + +class DataNetwork(TrackedResource): + """Data network resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the data network resource. Possible values + include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.models.ProvisioningState + :ivar description: An optional description for this data network. + :vartype description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword description: An optional description for this data network. + :paramtype description: str + """ + super(DataNetwork, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.description = description + + +class DataNetworkConfiguration(msrest.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. + :vartype data_network: ~mobile_network_management_client.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. + :vartype session_ambr: ~mobile_network_management_client.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 + selecting a GBR (Guaranteed Bit Rate) QoS. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, + 67, 71, 72, 73, 74, 75, 76, 82, 83, 84, and 85. See 3GPP TS23.501 section 5.7.2.1 for a full + description of the 5Qi parameter, and table 5.7.4-1 for the definition of which are the GBR 5QI + values. + :vartype five_qi: int + :ivar allocation_and_retention_priority_level: Default QoS Flow allocation and retention + priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the + settings of ``preemptionCapability`` and ``preemptionVulnerability`` allow it. 1 is the highest + level of priority. If this field is not specified then ``5qi`` is used to derive the ARP value. + See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + :vartype allocation_and_retention_priority_level: int + :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. Possible values + include: "NotPreempt", "MayPreempt". + :vartype preemption_capability: str or + ~mobile_network_management_client.models.PreemptionCapability + :ivar preemption_vulnerability: Default QoS Flow preemption vulnerability. The Preemption + Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher + priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + Possible values include: "NotPreemptable", "Preemptable". + :vartype preemption_vulnerability: str or + ~mobile_network_management_client.models.PreemptionVulnerability + :ivar default_session_type: The default PDU session type, which is used if the UE does not + request a specific session type. Possible values include: "IPv4", "IPv6". + :vartype default_session_type: str or ~mobile_network_management_client.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 + ~mobile_network_management_client.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. + :vartype allowed_services: list[~mobile_network_management_client.models.ServiceResourceId] + """ + + _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}, + } + + _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]'}, + } + + def __init__( + self, + *, + data_network: "DataNetworkResourceId", + session_ambr: "Ambr", + allowed_services: List["ServiceResourceId"], + five_qi: Optional[int] = None, + allocation_and_retention_priority_level: Optional[int] = None, + preemption_capability: Optional[Union[str, "PreemptionCapability"]] = None, + preemption_vulnerability: Optional[Union[str, "PreemptionVulnerability"]] = None, + default_session_type: Optional[Union[str, "PduSessionType"]] = None, + additional_allowed_session_types: Optional[List[Union[str, "PduSessionType"]]] = None, + **kwargs + ): + """ + :keyword data_network: Required. A reference to the Data Network that these settings apply to. + :paramtype data_network: ~mobile_network_management_client.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. + :paramtype session_ambr: ~mobile_network_management_client.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 + selecting a GBR (Guaranteed Bit Rate) QoS. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, + 67, 71, 72, 73, 74, 75, 76, 82, 83, 84, and 85. See 3GPP TS23.501 section 5.7.2.1 for a full + description of the 5Qi parameter, and table 5.7.4-1 for the definition of which are the GBR 5QI + values. + :paramtype five_qi: int + :keyword allocation_and_retention_priority_level: Default QoS Flow allocation and retention + priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the + settings of ``preemptionCapability`` and ``preemptionVulnerability`` allow it. 1 is the highest + level of priority. If this field is not specified then ``5qi`` is used to derive the ARP value. + See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + :paramtype allocation_and_retention_priority_level: int + :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. Possible + values include: "NotPreempt", "MayPreempt". + :paramtype preemption_capability: str or + ~mobile_network_management_client.models.PreemptionCapability + :keyword preemption_vulnerability: Default QoS Flow preemption vulnerability. The Preemption + Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher + priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + Possible values include: "NotPreemptable", "Preemptable". + :paramtype preemption_vulnerability: str or + ~mobile_network_management_client.models.PreemptionVulnerability + :keyword default_session_type: The default PDU session type, which is used if the UE does not + request a specific session type. Possible values include: "IPv4", "IPv6". + :paramtype default_session_type: str or ~mobile_network_management_client.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 + ~mobile_network_management_client.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. + :paramtype allowed_services: list[~mobile_network_management_client.models.ServiceResourceId] + """ + super(DataNetworkConfiguration, self).__init__(**kwargs) + self.data_network = data_network + self.session_ambr = session_ambr + self.five_qi = five_qi + self.allocation_and_retention_priority_level = allocation_and_retention_priority_level + self.preemption_capability = preemption_capability + self.preemption_vulnerability = preemption_vulnerability + self.default_session_type = default_session_type + self.additional_allowed_session_types = additional_allowed_session_types + self.allowed_services = allowed_services + + +class DataNetworkListResult(msrest.serialization.Model): + """Response for data network API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of data networks in a resource group. + :vartype value: list[~mobile_network_management_client.models.DataNetwork] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DataNetwork]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DataNetwork"]] = None, + **kwargs + ): + """ + :keyword value: A list of data networks in a resource group. + :paramtype value: list[~mobile_network_management_client.models.DataNetwork] + """ + super(DataNetworkListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DataNetworkResourceId(msrest.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. + :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]/[^/?#]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Data Network resource ID. + :paramtype id: str + """ + super(DataNetworkResourceId, self).__init__(**kwargs) + self.id = id + + +class ErrorAdditionalInfo(msrest.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: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.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[~mobile_network_management_client.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~mobile_network_management_client.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(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.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. + :vartype error: ~mobile_network_management_client.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~mobile_network_management_client.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class InterfaceProperties(msrest.serialization.Model): + """Interface properties. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The logical name for this interface. This should match one of the + interfaces configured on your Azure Stack Edge machine. + :vartype name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + """ + :keyword name: Required. The logical name for this interface. This should match one of the + interfaces configured on your Azure Stack Edge machine. + :paramtype name: str + """ + super(InterfaceProperties, self).__init__(**kwargs) + self.name = name + + +class MobileNetwork(TrackedResource): + """Mobile network resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the mobile network resource. Possible + values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.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. + :vartype public_land_mobile_network_identifier: ~mobile_network_management_client.models.PlmnId + :ivar service_key: The mobile network resource identifier. + :vartype service_key: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + '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__( + self, + *, + location: str, + public_land_mobile_network_identifier: "PlmnId", + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword 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. + :paramtype public_land_mobile_network_identifier: + ~mobile_network_management_client.models.PlmnId + """ + super(MobileNetwork, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.public_land_mobile_network_identifier = public_land_mobile_network_identifier + self.service_key = None + + +class MobileNetworkListResult(msrest.serialization.Model): + """Response for mobile networks API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of mobile networks in a resource group. + :vartype value: list[~mobile_network_management_client.models.MobileNetwork] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MobileNetwork]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["MobileNetwork"]] = None, + **kwargs + ): + """ + :keyword value: A list of mobile networks in a resource group. + :paramtype value: list[~mobile_network_management_client.models.MobileNetwork] + """ + super(MobileNetworkListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class MobileNetworkResourceId(msrest.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. + :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]/[^/?#]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Mobile Network resource ID. + :paramtype id: str + """ + super(MobileNetworkResourceId, self).__init__(**kwargs) + self.id = id + + +class NaptConfiguration(msrest.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 attachedDataNetwork. Possible + values include: "Enabled", "Disabled". Default value: "Enabled". + :vartype enabled: str or ~mobile_network_management_client.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 - 65,535. (Ports under + 1,024 should not be used because these are special purpose ports reserved by IANA.). + :vartype port_range: ~mobile_network_management_client.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. + :vartype port_reuse_hold_time: ~mobile_network_management_client.models.PortReuseHoldTimes + :ivar pinhole_limits: Maximum number of UDP and TCP pinholes that can be open simultaneously on + the core interface. + :vartype pinhole_limits: int + :ivar pinhole_timeouts: Expiry times of inactive NAPT pinholes, in seconds. All timers must be + at least 1 second. + :vartype pinhole_timeouts: ~mobile_network_management_client.models.PinholeTimeouts + """ + + _validation = { + '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'}, + } + + def __init__( + self, + *, + enabled: Optional[Union[str, "NaptEnabled"]] = "Enabled", + port_range: Optional["PortRange"] = None, + port_reuse_hold_time: Optional["PortReuseHoldTimes"] = None, + pinhole_limits: Optional[int] = 65536, + pinhole_timeouts: Optional["PinholeTimeouts"] = None, + **kwargs + ): + """ + :keyword enabled: Whether NAPT is enabled for connections to this attachedDataNetwork. Possible + values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype enabled: str or ~mobile_network_management_client.models.NaptEnabled + :keyword 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 - 65,535. (Ports under + 1,024 should not be used because these are special purpose ports reserved by IANA.). + :paramtype port_range: ~mobile_network_management_client.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. + :paramtype port_reuse_hold_time: ~mobile_network_management_client.models.PortReuseHoldTimes + :keyword pinhole_limits: Maximum number of UDP and TCP pinholes that can be open simultaneously + on the core interface. + :paramtype pinhole_limits: int + :keyword pinhole_timeouts: Expiry times of inactive NAPT pinholes, in seconds. All timers must + be at least 1 second. + :paramtype pinhole_timeouts: ~mobile_network_management_client.models.PinholeTimeouts + """ + super(NaptConfiguration, self).__init__(**kwargs) + self.enabled = enabled + self.port_range = port_range + self.port_reuse_hold_time = port_reuse_hold_time + self.pinhole_limits = pinhole_limits + self.pinhole_timeouts = pinhole_timeouts + + +class Operation(msrest.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. + + :ivar is_data_action: Indicates whether the operation applies to data-plane. + :vartype is_data_action: bool + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~mobile_network_management_client.models.OperationDisplay + """ + + _validation = { + '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'}, + } + + 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) + self.is_data_action = is_data_action + self.name = None + self.display = None + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.MobileNetwork. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Registration definition, + registration assignment etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.MobileNetwork. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Registration definition, + registration assignment etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationList(msrest.serialization.Model): + """List of the operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Microsoft.MobileNetwork operations. + :vartype value: list[~mobile_network_management_client.models.Operation] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class PacketCoreControlPlane(TrackedResource): + """Packet core control plane resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the packet core control plane resource. + Possible values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.models.ProvisioningState + :ivar mobile_network: Required. Mobile network that this packet core control plane belongs to. + :vartype mobile_network: ~mobile_network_management_client.models.MobileNetworkResourceId + :ivar custom_location: Azure ARC custom location where the packet core is deployed. + :vartype custom_location: ~mobile_network_management_client.models.CustomLocationResourceId + :ivar core_network_technology: The core network technology generation. Possible values include: + "5GC", "EPC". + :vartype core_network_technology: str or + ~mobile_network_management_client.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. In 5G networks this is called as N2 interface whereas in 4G networks this is called as + S1-MME interface. + :vartype control_plane_access_interface: + ~mobile_network_management_client.models.InterfaceProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'mobile_network': {'required': True}, + 'control_plane_access_interface': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'mobile_network': {'key': 'properties.mobileNetwork', 'type': 'MobileNetworkResourceId'}, + 'custom_location': {'key': 'properties.customLocation', 'type': 'CustomLocationResourceId'}, + 'core_network_technology': {'key': 'properties.coreNetworkTechnology', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'control_plane_access_interface': {'key': 'properties.controlPlaneAccessInterface', 'type': 'InterfaceProperties'}, + } + + def __init__( + self, + *, + location: str, + mobile_network: "MobileNetworkResourceId", + control_plane_access_interface: "InterfaceProperties", + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + custom_location: Optional["CustomLocationResourceId"] = None, + core_network_technology: Optional[Union[str, "CoreNetworkType"]] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword mobile_network: Required. Mobile network that this packet core control plane belongs + to. + :paramtype mobile_network: ~mobile_network_management_client.models.MobileNetworkResourceId + :keyword custom_location: Azure ARC custom location where the packet core is deployed. + :paramtype custom_location: ~mobile_network_management_client.models.CustomLocationResourceId + :keyword core_network_technology: The core network technology generation. Possible values + include: "5GC", "EPC". + :paramtype core_network_technology: str or + ~mobile_network_management_client.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. In 5G networks this is called as N2 interface whereas in 4G networks this is called as + S1-MME interface. + :paramtype control_plane_access_interface: + ~mobile_network_management_client.models.InterfaceProperties + """ + super(PacketCoreControlPlane, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.mobile_network = mobile_network + self.custom_location = custom_location + self.core_network_technology = core_network_technology + self.version = version + self.control_plane_access_interface = control_plane_access_interface + + +class PacketCoreControlPlaneListResult(msrest.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. + + :ivar value: A list of packet core control planes in a resource group. + :vartype value: list[~mobile_network_management_client.models.PacketCoreControlPlane] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PacketCoreControlPlane]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PacketCoreControlPlane"]] = None, + **kwargs + ): + """ + :keyword value: A list of packet core control planes in a resource group. + :paramtype value: list[~mobile_network_management_client.models.PacketCoreControlPlane] + """ + super(PacketCoreControlPlaneListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class PacketCoreDataPlane(TrackedResource): + """Packet core data plane resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the packet core data plane resource. + Possible values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.models.ProvisioningState + :ivar user_plane_access_interface: Required. The user plane interface on the access network. In + 5G networks this is called as N3 interface whereas in 4G networks this is called the S1-U + interface. + :vartype user_plane_access_interface: + ~mobile_network_management_client.models.InterfaceProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'user_plane_access_interface': {'key': 'properties.userPlaneAccessInterface', 'type': 'InterfaceProperties'}, + } + + def __init__( + self, + *, + location: str, + user_plane_access_interface: "InterfaceProperties", + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword user_plane_access_interface: Required. The user plane interface on the access network. + In 5G networks this is called as N3 interface whereas in 4G networks this is called the S1-U + interface. + :paramtype user_plane_access_interface: + ~mobile_network_management_client.models.InterfaceProperties + """ + super(PacketCoreDataPlane, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.user_plane_access_interface = user_plane_access_interface + + +class PacketCoreDataPlaneListResult(msrest.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. + + :ivar value: A list of packet core data planes in a resource group. + :vartype value: list[~mobile_network_management_client.models.PacketCoreDataPlane] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PacketCoreDataPlane]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PacketCoreDataPlane"]] = None, + **kwargs + ): + """ + :keyword value: A list of packet core data planes in a resource group. + :paramtype value: list[~mobile_network_management_client.models.PacketCoreDataPlane] + """ + super(PacketCoreDataPlaneListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class PccRuleConfiguration(msrest.serialization.Model): + """PCC 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``. + :vartype rule_name: str + :ivar rule_precedence: Required. A precedence value that is used to decide between PCC 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 PCC Rules configured in the Mobile Network. + :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 Service will define the QoS settings. + :vartype rule_qos_policy: ~mobile_network_management_client.models.PccRuleQosPolicy + :ivar traffic_control: Determines whether flows that match this PCC Rule are permitted. + Possible values include: "Enabled", "Blocked". + :vartype traffic_control: str or + ~mobile_network_management_client.models.TrafficControlPermission + :ivar service_data_flow_templates: Required. The set of service data flow templates to use for + this PCC Rule. + :vartype service_data_flow_templates: + list[~mobile_network_management_client.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}, + } + + _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]'}, + } + + def __init__( + self, + *, + rule_name: str, + rule_precedence: int, + service_data_flow_templates: List["ServiceDataFlowTemplate"], + rule_qos_policy: Optional["PccRuleQosPolicy"] = None, + traffic_control: Optional[Union[str, "TrafficControlPermission"]] = None, + **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``. + :paramtype rule_name: str + :keyword rule_precedence: Required. A precedence value that is used to decide between PCC 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 PCC Rules configured in the Mobile Network. + :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 Service will define the QoS settings. + :paramtype rule_qos_policy: ~mobile_network_management_client.models.PccRuleQosPolicy + :keyword traffic_control: Determines whether flows that match this PCC Rule are permitted. + Possible values include: "Enabled", "Blocked". + :paramtype traffic_control: str or + ~mobile_network_management_client.models.TrafficControlPermission + :keyword service_data_flow_templates: Required. The set of service data flow templates to use + for this PCC Rule. + :paramtype service_data_flow_templates: + list[~mobile_network_management_client.models.ServiceDataFlowTemplate] + """ + super(PccRuleConfiguration, self).__init__(**kwargs) + self.rule_name = rule_name + self.rule_precedence = rule_precedence + self.rule_qos_policy = rule_qos_policy + self.traffic_control = traffic_control + self.service_data_flow_templates = service_data_flow_templates + + +class QosPolicy(msrest.serialization.Model): + """QoS policy. + + All required parameters must be populated in order to send to Azure. + + :ivar five_qi: 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 selecting a GBR + (Guaranteed Bit Rate) QoS. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, 67, 71, 72, 73, + 74, 75, 76, 82, 83, 84, and 85. See 3GPP TS23.501 section 5.7.2.1 for a full description of the + 5Qi parameter, and table 5.7.4-1 for the definition of which are the GBR 5QI values. + :vartype five_qi: int + :ivar allocation_and_retention_priority_level: QoS Flow allocation and retention priority (ARP) + level. Flows with higher priority preempt flows with lower priority, if the settings of + ``preemptionCapability`` and ``preemptionVulnerability`` allow it. 1 is the highest level of + priority. If this field is not specified then ``5qi`` is used to derive the ARP value. See 3GPP + TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + :vartype allocation_and_retention_priority_level: int + :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. Possible values include: + "NotPreempt", "MayPreempt". + :vartype preemption_capability: str or + ~mobile_network_management_client.models.PreemptionCapability + :ivar preemption_vulnerability: QoS Flow preemption vulnerability. The Preemption + Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher + priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + Possible values include: "NotPreemptable", "Preemptable". + :vartype preemption_vulnerability: str or + ~mobile_network_management_client.models.PreemptionVulnerability + :ivar maximum_bit_rate: Required. The Maximum Bit Rate (MBR) for all service data flows that + use this PCC Rule or Service. + :vartype maximum_bit_rate: ~mobile_network_management_client.models.Ambr + """ + + _validation = { + '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'}, + } + + def __init__( + self, + *, + maximum_bit_rate: "Ambr", + five_qi: Optional[int] = None, + allocation_and_retention_priority_level: Optional[int] = None, + preemption_capability: Optional[Union[str, "PreemptionCapability"]] = None, + preemption_vulnerability: Optional[Union[str, "PreemptionVulnerability"]] = None, + **kwargs + ): + """ + :keyword five_qi: 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 + selecting a GBR (Guaranteed Bit Rate) QoS. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, + 67, 71, 72, 73, 74, 75, 76, 82, 83, 84, and 85. See 3GPP TS23.501 section 5.7.2.1 for a full + description of the 5Qi parameter, and table 5.7.4-1 for the definition of which are the GBR 5QI + values. + :paramtype five_qi: int + :keyword allocation_and_retention_priority_level: QoS Flow allocation and retention priority + (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of + ``preemptionCapability`` and ``preemptionVulnerability`` allow it. 1 is the highest level of + priority. If this field is not specified then ``5qi`` is used to derive the ARP value. See 3GPP + TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + :paramtype allocation_and_retention_priority_level: int + :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. Possible values include: + "NotPreempt", "MayPreempt". + :paramtype preemption_capability: str or + ~mobile_network_management_client.models.PreemptionCapability + :keyword preemption_vulnerability: QoS Flow preemption vulnerability. The Preemption + Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher + priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + Possible values include: "NotPreemptable", "Preemptable". + :paramtype preemption_vulnerability: str or + ~mobile_network_management_client.models.PreemptionVulnerability + :keyword maximum_bit_rate: Required. The Maximum Bit Rate (MBR) for all service data flows that + use this PCC Rule or Service. + :paramtype maximum_bit_rate: ~mobile_network_management_client.models.Ambr + """ + super(QosPolicy, self).__init__(**kwargs) + self.five_qi = five_qi + self.allocation_and_retention_priority_level = allocation_and_retention_priority_level + self.preemption_capability = preemption_capability + self.preemption_vulnerability = preemption_vulnerability + self.maximum_bit_rate = maximum_bit_rate + + +class PccRuleQosPolicy(QosPolicy): + """PCC rule QoS policy. + + All required parameters must be populated in order to send to Azure. + + :ivar five_qi: 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 selecting a GBR + (Guaranteed Bit Rate) QoS. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, 67, 71, 72, 73, + 74, 75, 76, 82, 83, 84, and 85. See 3GPP TS23.501 section 5.7.2.1 for a full description of the + 5Qi parameter, and table 5.7.4-1 for the definition of which are the GBR 5QI values. + :vartype five_qi: int + :ivar allocation_and_retention_priority_level: QoS Flow allocation and retention priority (ARP) + level. Flows with higher priority preempt flows with lower priority, if the settings of + ``preemptionCapability`` and ``preemptionVulnerability`` allow it. 1 is the highest level of + priority. If this field is not specified then ``5qi`` is used to derive the ARP value. See 3GPP + TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + :vartype allocation_and_retention_priority_level: int + :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. Possible values include: + "NotPreempt", "MayPreempt". + :vartype preemption_capability: str or + ~mobile_network_management_client.models.PreemptionCapability + :ivar preemption_vulnerability: QoS Flow preemption vulnerability. The Preemption + Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher + priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + Possible values include: "NotPreemptable", "Preemptable". + :vartype preemption_vulnerability: str or + ~mobile_network_management_client.models.PreemptionVulnerability + :ivar maximum_bit_rate: Required. The Maximum Bit Rate (MBR) for all service data flows that + use this PCC Rule or Service. + :vartype maximum_bit_rate: ~mobile_network_management_client.models.Ambr + :ivar guaranteed_bit_rate: The Guaranteed Bit Rate (GBR) for all service data flows that use + this PCC Rule. This is an optional setting. If you do not provide a value, there will be no GBR + set for the PCC Rule that uses this QoS definition. + :vartype guaranteed_bit_rate: ~mobile_network_management_client.models.Ambr + """ + + _validation = { + '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'}, + } + + def __init__( + self, + *, + maximum_bit_rate: "Ambr", + five_qi: Optional[int] = None, + allocation_and_retention_priority_level: Optional[int] = None, + preemption_capability: Optional[Union[str, "PreemptionCapability"]] = None, + preemption_vulnerability: Optional[Union[str, "PreemptionVulnerability"]] = None, + guaranteed_bit_rate: Optional["Ambr"] = None, + **kwargs + ): + """ + :keyword five_qi: 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 + selecting a GBR (Guaranteed Bit Rate) QoS. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, + 67, 71, 72, 73, 74, 75, 76, 82, 83, 84, and 85. See 3GPP TS23.501 section 5.7.2.1 for a full + description of the 5Qi parameter, and table 5.7.4-1 for the definition of which are the GBR 5QI + values. + :paramtype five_qi: int + :keyword allocation_and_retention_priority_level: QoS Flow allocation and retention priority + (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of + ``preemptionCapability`` and ``preemptionVulnerability`` allow it. 1 is the highest level of + priority. If this field is not specified then ``5qi`` is used to derive the ARP value. See 3GPP + TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + :paramtype allocation_and_retention_priority_level: int + :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. Possible values include: + "NotPreempt", "MayPreempt". + :paramtype preemption_capability: str or + ~mobile_network_management_client.models.PreemptionCapability + :keyword preemption_vulnerability: QoS Flow preemption vulnerability. The Preemption + Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher + priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + Possible values include: "NotPreemptable", "Preemptable". + :paramtype preemption_vulnerability: str or + ~mobile_network_management_client.models.PreemptionVulnerability + :keyword maximum_bit_rate: Required. The Maximum Bit Rate (MBR) for all service data flows that + use this PCC Rule or Service. + :paramtype maximum_bit_rate: ~mobile_network_management_client.models.Ambr + :keyword guaranteed_bit_rate: The Guaranteed Bit Rate (GBR) for all service data flows that use + this PCC Rule. This is an optional setting. If you do not provide a value, there will be no GBR + set for the PCC Rule that uses this QoS definition. + :paramtype guaranteed_bit_rate: ~mobile_network_management_client.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) + self.guaranteed_bit_rate = guaranteed_bit_rate + + +class PinholeTimeouts(msrest.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 + per RFC 5382 section 5. + :vartype tcp: int + :ivar udp: Pinhole timeout for UDP pinholes in seconds. Default for UDP is 5 minutes per RFC + 4787 section 4.3. + :vartype udp: int + :ivar icmp: Pinhole timeout for ICMP pinholes in seconds. Default for ICMP Echo is 60 seconds + per RFC 5508 section 3.2. + :vartype icmp: int + """ + + _validation = { + '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'}, + } + + def __init__( + self, + *, + tcp: Optional[int] = 7440, + udp: Optional[int] = 300, + icmp: Optional[int] = 60, + **kwargs + ): + """ + :keyword tcp: Pinhole timeout for TCP pinholes in seconds. Default for TCP is 2 hours 4 minutes + per RFC 5382 section 5. + :paramtype tcp: int + :keyword udp: Pinhole timeout for UDP pinholes in seconds. Default for UDP is 5 minutes per RFC + 4787 section 4.3. + :paramtype udp: int + :keyword icmp: Pinhole timeout for ICMP pinholes in seconds. Default for ICMP Echo is 60 + seconds per RFC 5508 section 3.2. + :paramtype icmp: int + """ + super(PinholeTimeouts, self).__init__(**kwargs) + self.tcp = tcp + self.udp = udp + self.icmp = icmp + + +class PlmnId(msrest.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). + :vartype mcc: str + :ivar mnc: Required. Mobile Network Code (MNC). + :vartype mnc: str + """ + + _validation = { + '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'}, + } + + def __init__( + self, + *, + mcc: str, + mnc: str, + **kwargs + ): + """ + :keyword mcc: Required. Mobile Country Code (MCC). + :paramtype mcc: str + :keyword mnc: Required. Mobile Network Code (MNC). + :paramtype mnc: str + """ + super(PlmnId, self).__init__(**kwargs) + self.mcc = mcc + self.mnc = mnc + + +class PortRange(msrest.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 - 65,535. (Ports under 1,024 should not be used because these are special purpose ports reserved by IANA.). + + :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}, + } + + _attribute_map = { + 'min_port': {'key': 'minPort', 'type': 'int'}, + 'max_port': {'key': 'maxPort', 'type': 'int'}, + } + + def __init__( + self, + *, + min_port: Optional[int] = 1024, + max_port: Optional[int] = 65535, + **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) + self.min_port = min_port + self.max_port = max_port + + +class PortReuseHoldTimes(msrest.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 + pinhole can be reused. Default for TCP is 2 minutes. + :vartype tcp: int + :ivar udp: Minimum time in seconds that will pass before a UDP port that was used by a closed + pinhole can be reused. Default for UDP is 1 minute. + :vartype udp: int + """ + + _validation = { + 'tcp': {'minimum': 1}, + 'udp': {'minimum': 1}, + } + + _attribute_map = { + 'tcp': {'key': 'tcp', 'type': 'int'}, + 'udp': {'key': 'udp', 'type': 'int'}, + } + + def __init__( + self, + *, + tcp: Optional[int] = 120, + udp: Optional[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. + :paramtype tcp: int + :keyword udp: Minimum time in seconds that will pass before a UDP port that was used by a + closed pinhole can be reused. Default for UDP is 1 minute. + :paramtype udp: int + """ + super(PortReuseHoldTimes, self).__init__(**kwargs) + self.tcp = tcp + self.udp = udp + + +class Service(TrackedResource): + """Service resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the service resource. Possible values + include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.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. + :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 simPolicy will define the QoS settings. + :vartype service_qos_policy: ~mobile_network_management_client.models.QosPolicy + :ivar pcc_rules: Required. The set of PCC Rules that make up this service. + :vartype pcc_rules: list[~mobile_network_management_client.models.PccRuleConfiguration] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + '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__( + self, + *, + location: str, + service_precedence: int, + pcc_rules: List["PccRuleConfiguration"], + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + service_qos_policy: Optional["QosPolicy"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :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. + :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 simPolicy will define the QoS settings. + :paramtype service_qos_policy: ~mobile_network_management_client.models.QosPolicy + :keyword pcc_rules: Required. The set of PCC Rules that make up this service. + :paramtype pcc_rules: list[~mobile_network_management_client.models.PccRuleConfiguration] + """ + super(Service, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + 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): + """Service data flow (SDF) template. + + All required parameters must be populated in order to send to Azure. + + :ivar template_name: Required. The name of the SDF template. This must be unique within the + parent PccRuleConfiguration. You must not use any of the following reserved strings - + ``default``\ , ``requested`` or ``service``. + :vartype template_name: str + :ivar direction: Required. The direction of this flow. Possible values include: "Uplink", + "Downlink", "Bidirectional". + :vartype direction: str or ~mobile_network_management_client.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 + 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. + :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 Fusion Core will connect for this flow. + You must provide each IP address in CIDR notation, including the netmask (for example, + 192.0.2.54/24). + :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 + value other than ``ip`` in the ``protocol`` field. This is an optional setting. If you do not + specify it then connections will be allowed on all ports. Port ranges must be specified as + :code:``-:code:``. For example: [\ ``8080``\ , ``8082-8085``\ ]. + :vartype ports: list[str] + """ + + _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}, + } + + _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]'}, + } + + def __init__( + self, + *, + template_name: str, + direction: Union[str, "SdfDirection"], + protocol: List[str], + remote_ip_list: List[str], + ports: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword template_name: Required. The name of the SDF template. This must be unique within the + parent PccRuleConfiguration. You must not use any of the following reserved strings - + ``default``\ , ``requested`` or ``service``. + :paramtype template_name: str + :keyword direction: Required. The direction of this flow. Possible values include: "Uplink", + "Downlink", "Bidirectional". + :paramtype direction: str or ~mobile_network_management_client.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 + 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. + :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 Fusion Core will connect for this flow. + You must provide each IP address in CIDR notation, including the netmask (for example, + 192.0.2.54/24). + :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 + specify a value other than ``ip`` in the ``protocol`` field. This is an optional setting. If + you do not specify it then connections will be allowed on all ports. Port ranges must be + specified as :code:``-:code:``. For example: [\ ``8080``\ , ``8082-8085``\ + ]. + :paramtype ports: list[str] + """ + super(ServiceDataFlowTemplate, self).__init__(**kwargs) + self.template_name = template_name + self.direction = direction + self.protocol = protocol + self.remote_ip_list = remote_ip_list + self.ports = ports + + +class ServiceListResult(msrest.serialization.Model): + """Response for Services API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of Services. + :vartype value: list[~mobile_network_management_client.models.Service] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Service]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Service"]] = None, + **kwargs + ): + """ + :keyword value: A list of Services. + :paramtype value: list[~mobile_network_management_client.models.Service] + """ + super(ServiceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ServiceResourceId(msrest.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. + :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]/[^/?#]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Service resource ID. + :paramtype id: str + """ + super(ServiceResourceId, self).__init__(**kwargs) + self.id = id + + +class Sim(TrackedResource): + """Sim resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the sim resource. Possible values include: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.models.ProvisioningState + :ivar configuration_state: The configuration state of the sim resource - complete or + incomplete. Possible values include: "Incomplete", "Complete". + :vartype configuration_state: str or + ~mobile_network_management_client.models.ConfigurationState + :ivar international_mobile_subscriber_identity: Required. The International Mobile Subscriber + Identity (IMSI) for the sim. + :vartype international_mobile_subscriber_identity: str + :ivar integrated_circuit_card_identifier: The Integrated Circuit Card ID (ICC Id) 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 mobile_network: Mobile network that this sim belongs to. + :vartype mobile_network: ~mobile_network_management_client.models.MobileNetworkResourceId + :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 simPolicy used by this sim. + :vartype sim_policy: ~mobile_network_management_client.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[~mobile_network_management_client.models.SimStaticIpProperties] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'configuration_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}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'configuration_state': {'key': 'properties.configurationState', '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'}, + 'mobile_network': {'key': 'properties.mobileNetwork', 'type': 'MobileNetworkResourceId'}, + 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, + 'sim_policy': {'key': 'properties.simPolicy', 'type': 'SimPolicyResourceId'}, + 'static_ip_configuration': {'key': 'properties.staticIpConfiguration', 'type': '[SimStaticIpProperties]'}, + } + + def __init__( + self, + *, + location: str, + international_mobile_subscriber_identity: str, + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + integrated_circuit_card_identifier: Optional[str] = None, + authentication_key: Optional[str] = None, + operator_key_code: Optional[str] = None, + mobile_network: Optional["MobileNetworkResourceId"] = None, + device_type: Optional[str] = None, + sim_policy: Optional["SimPolicyResourceId"] = None, + static_ip_configuration: Optional[List["SimStaticIpProperties"]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword international_mobile_subscriber_identity: Required. The International Mobile + Subscriber Identity (IMSI) for the sim. + :paramtype international_mobile_subscriber_identity: str + :keyword integrated_circuit_card_identifier: The Integrated Circuit Card ID (ICC Id) 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 mobile_network: Mobile network that this sim belongs to. + :paramtype mobile_network: ~mobile_network_management_client.models.MobileNetworkResourceId + :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 simPolicy used by this sim. + :paramtype sim_policy: ~mobile_network_management_client.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[~mobile_network_management_client.models.SimStaticIpProperties] + """ + super(Sim, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.configuration_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.mobile_network = mobile_network + self.device_type = device_type + self.sim_policy = sim_policy + self.static_ip_configuration = static_ip_configuration + + +class SimIdListResult(msrest.serialization.Model): + """Response for list sim ids API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of sim profile ids in a resource group. + :vartype value: list[~mobile_network_management_client.models.SubResource] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SubResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["SubResource"]] = None, + **kwargs + ): + """ + :keyword value: A list of sim profile ids in a resource group. + :paramtype value: list[~mobile_network_management_client.models.SubResource] + """ + super(SimIdListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class SimListResult(msrest.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 Sims in a resource group. + :vartype value: list[~mobile_network_management_client.models.Sim] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Sim]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Sim"]] = None, + **kwargs + ): + """ + :keyword value: A list of Sims in a resource group. + :paramtype value: list[~mobile_network_management_client.models.Sim] + """ + super(SimListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class SimPolicy(TrackedResource): + """Sim policy resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the sim policy resource. Possible values + include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.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. + :vartype ue_ambr: ~mobile_network_management_client.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. + :vartype default_slice: ~mobile_network_management_client.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. + :vartype rfsp_index: int + :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. + :vartype slice_configurations: + list[~mobile_network_management_client.models.SliceConfiguration] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'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}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + '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]'}, + } + + def __init__( + self, + *, + location: str, + ue_ambr: "Ambr", + default_slice: "SliceResourceId", + slice_configurations: List["SliceConfiguration"], + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + rfsp_index: Optional[int] = None, + registration_timer: Optional[int] = 3240, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :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. + :paramtype ue_ambr: ~mobile_network_management_client.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. + :paramtype default_slice: ~mobile_network_management_client.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. + :paramtype rfsp_index: int + :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. + :paramtype slice_configurations: + list[~mobile_network_management_client.models.SliceConfiguration] + """ + super(SimPolicy, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.ue_ambr = ue_ambr + self.default_slice = default_slice + self.rfsp_index = rfsp_index + self.registration_timer = registration_timer + self.slice_configurations = slice_configurations + + +class SimPolicyListResult(msrest.serialization.Model): + """Response for SimPolicies API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of SimPolicies. + :vartype value: list[~mobile_network_management_client.models.SimPolicy] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SimPolicy]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["SimPolicy"]] = None, + **kwargs + ): + """ + :keyword value: A list of SimPolicies. + :paramtype value: list[~mobile_network_management_client.models.SimPolicy] + """ + super(SimPolicyListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class SimPolicyResourceId(msrest.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. + :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]/[^/?#]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. SIM Policy resource ID. + :paramtype id: str + """ + super(SimPolicyResourceId, self).__init__(**kwargs) + self.id = id + + +class SimStaticIpProperties(msrest.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 attachedDataNetwork and slice defines the network scope of the IP + address. + :vartype attached_data_network: + ~mobile_network_management_client.models.AttachedDataNetworkResourceId + :ivar slice: The network slice on which the static IP address will be used. The combination of + attachedDataNetwork and slice defines the network scope of the IP address. + :vartype slice: ~mobile_network_management_client.models.SliceResourceId + :ivar static_ip: The static IP configuration for the sim to use at the defined network scope. + :vartype static_ip: ~mobile_network_management_client.models.SimStaticIpPropertiesStaticIp + """ + + _attribute_map = { + 'attached_data_network': {'key': 'attachedDataNetwork', 'type': 'AttachedDataNetworkResourceId'}, + 'slice': {'key': 'slice', 'type': 'SliceResourceId'}, + 'static_ip': {'key': 'staticIp', 'type': 'SimStaticIpPropertiesStaticIp'}, + } + + def __init__( + self, + *, + attached_data_network: Optional["AttachedDataNetworkResourceId"] = None, + slice: Optional["SliceResourceId"] = None, + static_ip: Optional["SimStaticIpPropertiesStaticIp"] = None, + **kwargs + ): + """ + :keyword attached_data_network: The attached data network on which the static IP address will + be used. The combination of attachedDataNetwork and slice defines the network scope of the IP + address. + :paramtype attached_data_network: + ~mobile_network_management_client.models.AttachedDataNetworkResourceId + :keyword slice: The network slice on which the static IP address will be used. The combination + of attachedDataNetwork and slice defines the network scope of the IP address. + :paramtype slice: ~mobile_network_management_client.models.SliceResourceId + :keyword static_ip: The static IP configuration for the sim to use at the defined network + scope. + :paramtype static_ip: ~mobile_network_management_client.models.SimStaticIpPropertiesStaticIp + """ + super(SimStaticIpProperties, self).__init__(**kwargs) + self.attached_data_network = attached_data_network + self.slice = slice + self.static_ip = static_ip + + +class SimStaticIpPropertiesStaticIp(msrest.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 + must be in the userEquipmentStaticAddressPoolPrefix defined in the attachedDataNetwork. + :vartype ipv4_address: str + """ + + _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])$'}, + } + + _attribute_map = { + 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, + } + + 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 attachedDataNetwork. + :paramtype ipv4_address: str + """ + super(SimStaticIpPropertiesStaticIp, self).__init__(**kwargs) + self.ipv4_address = ipv4_address + + +class Site(TrackedResource): + """Site resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the site resource. **TODO**\ : Confirm if + this is needed. Possible values include: "Unknown", "Succeeded", "Accepted", "Deleting", + "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.models.ProvisioningState + :ivar network_functions: An array of ids of the network functions deployed on the site, + maintained by the user. + :vartype network_functions: list[~mobile_network_management_client.models.SubResource] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + '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, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + network_functions: Optional[List["SubResource"]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword network_functions: An array of ids of the network functions deployed on the site, + maintained by the user. + :paramtype network_functions: list[~mobile_network_management_client.models.SubResource] + """ + super(Site, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.network_functions = network_functions + + +class SiteListResult(msrest.serialization.Model): + """Response for sites API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of sites in a resource group. + :vartype value: list[~mobile_network_management_client.models.Site] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Site]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Site"]] = None, + **kwargs + ): + """ + :keyword value: A list of sites in a resource group. + :paramtype value: list[~mobile_network_management_client.models.Site] + """ + super(SiteListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class Slice(TrackedResource): + """Network slice resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the network slice resource. Possible values + include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~mobile_network_management_client.models.ProvisioningState + :ivar snssai: Required. The S-NSSAI (single network slice selection assistance information). + Unique at the scope of a MobileNetwork. + :vartype snssai: ~mobile_network_management_client.models.Snssai + :ivar description: An optional description for this network slice. + :vartype description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'snssai': {'key': 'properties.snssai', 'type': 'Snssai'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + snssai: "Snssai", + tags: Optional[Dict[str, str]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~mobile_network_management_client.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. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~mobile_network_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + :keyword snssai: Required. The S-NSSAI (single network slice selection assistance information). + Unique at the scope of a MobileNetwork. + :paramtype snssai: ~mobile_network_management_client.models.Snssai + :keyword description: An optional description for this network slice. + :paramtype description: str + """ + super(Slice, self).__init__(tags=tags, location=location, **kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + self.provisioning_state = None + self.snssai = snssai + self.description = description + + +class SliceConfiguration(msrest.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. + :vartype slice: ~mobile_network_management_client.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. + :vartype default_data_network: ~mobile_network_management_client.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. + :vartype data_network_configurations: + list[~mobile_network_management_client.models.DataNetworkConfiguration] + """ + + _validation = { + '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]'}, + } + + def __init__( + self, + *, + slice: "SliceResourceId", + default_data_network: "DataNetworkResourceId", + data_network_configurations: List["DataNetworkConfiguration"], + **kwargs + ): + """ + :keyword slice: Required. A reference to the Slice that these settings apply to. + :paramtype slice: ~mobile_network_management_client.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. + :paramtype default_data_network: ~mobile_network_management_client.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. + :paramtype data_network_configurations: + list[~mobile_network_management_client.models.DataNetworkConfiguration] + """ + super(SliceConfiguration, self).__init__(**kwargs) + self.slice = slice + self.default_data_network = default_data_network + self.data_network_configurations = data_network_configurations + + +class SliceListResult(msrest.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. + + :ivar value: A list of data networks in a resource group. + :vartype value: list[~mobile_network_management_client.models.Slice] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Slice]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Slice"]] = None, + **kwargs + ): + """ + :keyword value: A list of data networks in a resource group. + :paramtype value: list[~mobile_network_management_client.models.Slice] + """ + super(SliceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class SliceResourceId(msrest.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. + :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]/[^/?#]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Slice resource ID. + :paramtype id: str + """ + super(SliceResourceId, self).__init__(**kwargs) + self.id = id + + +class Snssai(msrest.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). + :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}$'}, + } + + _attribute_map = { + 'sst': {'key': 'sst', 'type': 'int'}, + 'sd': {'key': 'sd', 'type': 'str'}, + } + + def __init__( + self, + *, + sst: int, + sd: Optional[str] = None, + **kwargs + ): + """ + :keyword sst: Required. Slice/Service Type (SST). + :paramtype sst: int + :keyword sd: Slice Differentiator (SD). + :paramtype sd: str + """ + super(Snssai, self).__init__(**kwargs) + self.sst = sst + self.sd = sd + + +class SubResource(msrest.serialization.Model): + """Reference to another sub resource. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. Resource ID. + :vartype id: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Resource ID. + :paramtype id: str + """ + super(SubResource, self).__init__(**kwargs) + self.id = id + + +class TagsObject(msrest.serialization.Model): + """Tags object for patch operations. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(TagsObject, self).__init__(**kwargs) + self.tags = tags 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 new file mode 100644 index 000000000000..349366a76107 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py @@ -0,0 +1,33 @@ +# 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 ._attached_data_networks_operations import AttachedDataNetworksOperations +from ._data_networks_operations import DataNetworksOperations +from ._mobile_networks_operations import MobileNetworksOperations +from ._sites_operations import SitesOperations +from ._sims_operations import SimsOperations +from ._operations import Operations +from ._packet_core_control_planes_operations import PacketCoreControlPlanesOperations +from ._packet_core_data_planes_operations import PacketCoreDataPlanesOperations +from ._services_operations import ServicesOperations +from ._sim_policies_operations import SimPoliciesOperations +from ._slices_operations import SlicesOperations + +__all__ = [ + 'AttachedDataNetworksOperations', + 'DataNetworksOperations', + 'MobileNetworksOperations', + 'SitesOperations', + 'SimsOperations', + 'Operations', + 'PacketCoreControlPlanesOperations', + 'PacketCoreDataPlanesOperations', + 'ServicesOperations', + 'SimPoliciesOperations', + 'SlicesOperations', +] 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 new file mode 100644 index 000000000000..92e73ce5a28f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_attached_data_networks_operations.py @@ -0,0 +1,712 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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, + packet_core_data_plane_name: str, + attached_data_network_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}') + 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_-]*$'), + "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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_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: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}') + 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_-]*$'), + "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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}') + 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_-]*$'), + "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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_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, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}') + 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_-]*$'), + "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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_packet_core_data_plane_request( + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class AttachedDataNetworksOperations(object): + """AttachedDataNetworksOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_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, + attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + 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 + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified attached data network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_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, + attached_data_network_name=attached_data_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + **kwargs: Any + ) -> "_models.AttachedDataNetwork": + """Gets information about the specified attached data network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :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) + :rtype: ~mobile_network_management_client.models.AttachedDataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + attached_data_network_name: str, + parameters: "_models.AttachedDataNetwork", + **kwargs: Any + ) -> "_models.AttachedDataNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AttachedDataNetwork') + + request = build_create_or_update_request_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, + attached_data_network_name=attached_data_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}'} # type: ignore + + + @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: "_models.AttachedDataNetwork", + **kwargs: Any + ) -> LROPoller["_models.AttachedDataNetwork"]: + """Creates or updates an attached data network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :type attached_data_network_name: str + :param parameters: Parameters supplied to the create or update attached data network operation. + :type parameters: ~mobile_network_management_client.models.AttachedDataNetwork + :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[~mobile_network_management_client.models.AttachedDataNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + 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._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, + attached_data_network_name=attached_data_network_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AttachedDataNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}/attachedDataNetworks/{attachedDataNetworkName}'} # type: ignore + + @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: "_models.TagsObject", + **kwargs: Any + ) -> "_models.AttachedDataNetwork": + """Updates an attached data network update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param attached_data_network_name: The name of the attached data network. + :type attached_data_network_name: str + :param parameters: Parameters supplied to update attached data network tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AttachedDataNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.AttachedDataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_packet_core_data_plane( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> Iterable["_models.AttachedDataNetworkListResult"]: + """Gets all the data networks associated with a packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :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[~mobile_network_management_client.models.AttachedDataNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDataNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_packet_core_data_plane_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, + template_url=self.list_by_packet_core_data_plane.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_packet_core_data_plane_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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + 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 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 new file mode 100644 index 000000000000..98298e1f408f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_data_networks_operations.py @@ -0,0 +1,677 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}') + 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])*)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}') + 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])*)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}') + 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])*)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}') + 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])*)*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_mobile_network_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class DataNetworksOperations(object): + """DataNetworksOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified mobile network dataNetwork. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + **kwargs: Any + ) -> "_models.DataNetwork": + """Gets information about the specified mobile network dataNetwork. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :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) + :rtype: ~mobile_network_management_client.models.DataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: "_models.DataNetwork", + **kwargs: Any + ) -> "_models.DataNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DataNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('DataNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DataNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: "_models.DataNetwork", + **kwargs: Any + ) -> LROPoller["_models.DataNetwork"]: + """Creates or updates a mobile network dataNetwork. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :type data_network_name: str + :param parameters: Parameters supplied to the create or update mobile network dataNetwork + operation. + :type parameters: ~mobile_network_management_client.models.DataNetwork + :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[~mobile_network_management_client.models.DataNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + data_network_name=data_network_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DataNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks/{dataNetworkName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + data_network_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.DataNetwork": + """Update data network tags. + + :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 + :param data_network_name: The name of the mobile network dataNetwork. + :type data_network_name: str + :param parameters: Parameters supplied to update data network tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.DataNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> Iterable["_models.DataNetworkListResult"]: + """Lists all dataNetworks in the 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 + :return: An iterator like instance of either DataNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.DataNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/dataNetworks'} # type: ignore 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 new file mode 100644 index 000000000000..71376e79e164 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_mobile_networks_operations.py @@ -0,0 +1,881 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_sim_ids_request_initial( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/listSimIds') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class MobileNetworksOperations(object): + """MobileNetworksOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + + @distributed_trace + 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + @distributed_trace + 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. + :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 + :return: MobileNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.MobileNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: "_models.MobileNetwork", + **kwargs: Any + ) -> "_models.MobileNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MobileNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('MobileNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('MobileNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: "_models.MobileNetwork", + **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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param parameters: Parameters supplied to the create or update mobile network operation. + :type parameters: ~mobile_network_management_client.models.MobileNetwork + :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[~mobile_network_management_client.models.MobileNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('MobileNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.MobileNetwork": + """Updates a mobile network update tags. + + :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 + :param parameters: Parameters supplied to update mobile network tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MobileNetwork, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.MobileNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.MobileNetworkListResult"]: + """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[~mobile_network_management_client.models.MobileNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/mobileNetworks'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.MobileNetworkListResult"]: + """Lists all the mobile networks in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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[~mobile_network_management_client.models.MobileNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MobileNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + 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": + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimIdListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self._list_sim_ids_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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"]: + """List sim ids under 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[~mobile_network_management_client.models.SimIdListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimIdListResult"] + 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( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('SimIdListResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + 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 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 new file mode 100644 index 000000000000..ebdcce0363be --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_operations.py @@ -0,0 +1,135 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.MobileNetwork/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationList"]: + """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[~mobile_network_management_client.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.MobileNetwork/operations'} # type: ignore 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 new file mode 100644 index 000000000000..175a3659fb37 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py @@ -0,0 +1,740 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + packet_core_control_plane_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + packet_core_control_plane_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + packet_core_control_plane_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class PacketCoreControlPlanesOperations(object): + """PacketCoreControlPlanesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + + @distributed_trace + 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. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + @distributed_trace + def get( + 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. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :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) + :rtype: ~mobile_network_management_client.models.PacketCoreControlPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: "_models.PacketCoreControlPlane", + **kwargs: Any + ) -> "_models.PacketCoreControlPlane": + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PacketCoreControlPlane') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: "_models.PacketCoreControlPlane", + **kwargs: Any + ) -> LROPoller["_models.PacketCoreControlPlane"]: + """Creates or updates a PacketCoreControlPlane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the create or update packet core control plane + operation. + :type parameters: ~mobile_network_management_client.models.PacketCoreControlPlane + :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[~mobile_network_management_client.models.PacketCoreControlPlane] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('PacketCoreControlPlane', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.PacketCoreControlPlane": + """Updates a PacketCoreControlPlane update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to update PacketCoreControlPlane tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PacketCoreControlPlane, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.PacketCoreControlPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.PacketCoreControlPlaneListResult"]: + """Lists all the packetCoreControlPlanes 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 + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.PacketCoreControlPlaneListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlaneListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.PacketCoreControlPlaneListResult"]: + """Lists all the packetCoreControlPlanes in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.PacketCoreControlPlaneListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreControlPlaneListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes'} # type: ignore 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 new file mode 100644 index 000000000000..fa39d1ff372d --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_data_planes_operations.py @@ -0,0 +1,678 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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, + packet_core_data_plane_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class PacketCoreDataPlanesOperations(object): + """PacketCoreDataPlanesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_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, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + **kwargs: Any + ) -> "_models.PacketCoreDataPlane": + """Gets information about the specified packet core data plane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :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) + :rtype: ~mobile_network_management_client.models.PacketCoreDataPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + 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", + **kwargs: Any + ) -> "_models.PacketCoreDataPlane": + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PacketCoreDataPlane') + + request = build_create_or_update_request_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, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + + @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: "_models.PacketCoreDataPlane", + **kwargs: Any + ) -> LROPoller["_models.PacketCoreDataPlane"]: + """Creates or updates a PacketCoreDataPlane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to the create or update packet core data plane + operation. + :type parameters: ~mobile_network_management_client.models.PacketCoreDataPlane + :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[~mobile_network_management_client.models.PacketCoreDataPlane] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + 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._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, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('PacketCoreDataPlane', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + packet_core_data_plane_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.PacketCoreDataPlane": + """Updates a PacketCoreDataPlane update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :type packet_core_control_plane_name: str + :param packet_core_data_plane_name: The name of the packet core data plane. + :type packet_core_data_plane_name: str + :param parameters: Parameters supplied to update PacketCoreDataPlane tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PacketCoreDataPlane, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.PacketCoreDataPlane + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlane"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @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"]: + """Lists all the packetCoreDataPlanes associated with a packetCoreControlPlane. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. + :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[~mobile_network_management_client.models.PacketCoreDataPlaneListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PacketCoreDataPlaneListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_packet_core_control_plane.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + 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 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 new file mode 100644 index 000000000000..e24aba2ced24 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_services_operations.py @@ -0,0 +1,678 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + mobile_network_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + mobile_network_name: str, + service_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_mobile_network_request( + resource_group_name: str, + mobile_network_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class ServicesOperations(object): + """ServicesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + + @distributed_trace + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :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``. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + @distributed_trace + def get( + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :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``. + :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) + :rtype: ~mobile_network_management_client.models.Service + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: "_models.Service", + **kwargs: Any + ) -> "_models.Service": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Service') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Service', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Service', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: "_models.Service", + **kwargs: Any + ) -> LROPoller["_models.Service"]: + """Creates or updates a Service. + + :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 + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. + :type service_name: str + :param parameters: Parameters supplied to the create or update service operation. + :type parameters: ~mobile_network_management_client.models.Service + :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[~mobile_network_management_client.models.Service] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + service_name=service_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Service', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services/{serviceName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + service_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Service": + """Update service tags. + + :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 + :param service_name: The name of the service. You must not use any of the following reserved + strings - ``default``\ , ``requested`` or ``service``. + :type service_name: str + :param parameters: Parameters supplied to update service tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Service, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Service + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Service"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> Iterable["_models.ServiceListResult"]: + """Gets all the services 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 + :return: An iterator like instance of either ServiceListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.ServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/services'} # type: ignore 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 new file mode 100644 index 000000000000..b7f6707652ef --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_policies_operations.py @@ -0,0 +1,674 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_mobile_network_request( + resource_group_name: str, + mobile_network_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class SimPoliciesOperations(object): + """SimPoliciesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + + @distributed_trace + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + @distributed_trace + def get( + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param sim_policy_name: The name of the SIM policy. + :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) + :rtype: ~mobile_network_management_client.models.SimPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: "_models.SimPolicy", + **kwargs: Any + ) -> "_models.SimPolicy": + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SimPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('SimPolicy', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SimPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: "_models.SimPolicy", + **kwargs: Any + ) -> LROPoller["_models.SimPolicy"]: + """Creates or updates a SimPolicy. + + :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 + :param sim_policy_name: The name of the SIM policy. + :type sim_policy_name: str + :param parameters: Parameters supplied to the create or update sim policy operation. + :type parameters: ~mobile_network_management_client.models.SimPolicy + :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[~mobile_network_management_client.models.SimPolicy] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + sim_policy_name=sim_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('SimPolicy', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies/{simPolicyName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + sim_policy_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.SimPolicy": + """Update sim policy tags. + + :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 + :param sim_policy_name: The name of the SIM policy. + :type sim_policy_name: str + :param parameters: Parameters supplied to update Sim Policy tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimPolicy, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.SimPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> Iterable["_models.SimPolicyListResult"]: + """Gets all the simPolicies 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 + :return: An iterator like instance of either SimPolicyListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.SimPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/simPolicies'} # type: ignore 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 new file mode 100644 index 000000000000..18ff27537e49 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py @@ -0,0 +1,733 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}') + 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), + "simName": _SERIALIZER.url("sim_name", sim_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + sim_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}') + 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), + "simName": _SERIALIZER.url("sim_name", sim_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + sim_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}') + 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), + "simName": _SERIALIZER.url("sim_name", sim_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + subscription_id: str, + resource_group_name: str, + sim_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}') + 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), + "simName": _SERIALIZER.url("sim_name", sim_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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/sims') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class SimsOperations(object): + """SimsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + sim_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_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. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + sim_name=sim_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_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. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :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) + :rtype: ~mobile_network_management_client.models.Sim + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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/sims/{simName}'} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + sim_name: str, + parameters: "_models.Sim", + **kwargs: Any + ) -> "_models.Sim": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Sim') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Sim', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Sim', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + sim_name: str, + parameters: "_models.Sim", + **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. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :type sim_name: str + :param parameters: Parameters supplied to the create or update sim operation. + :type parameters: ~mobile_network_management_client.models.Sim + :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[~mobile_network_management_client.models.Sim] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + sim_name=sim_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Sim', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + sim_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Sim": + """Updates a sim update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param sim_name: The name of the SIM. + :type sim_name: str + :param parameters: Parameters supplied to update sim tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Sim, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Sim + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Sim"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + sim_name=sim_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Sim', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims/{simName}'} # type: ignore + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.SimListResult"]: + """Gets all the sims 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 SimListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.SimListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.MobileNetwork/sims'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SimListResult"]: + """Gets all the Sims in a subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 SimListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.SimListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SimListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/sims'} # type: ignore 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 new file mode 100644 index 000000000000..47014cb8da9f --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sites_operations.py @@ -0,0 +1,673 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_mobile_network_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class SitesOperations(object): + """SitesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + + @distributed_trace + 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. + + :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 + :param site_name: The name of the mobile network site. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + @distributed_trace + 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. + :type resource_group_name: str + :param mobile_network_name: The name of the mobile network. + :type mobile_network_name: str + :param site_name: The name of the mobile network site. + :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) + :rtype: ~mobile_network_management_client.models.Site + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: "_models.Site", + **kwargs: Any + ) -> "_models.Site": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Site') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Site', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Site', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: "_models.Site", + **kwargs: Any + ) -> LROPoller["_models.Site"]: + """Creates or updates a mobile network site. + + :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 + :param site_name: The name of the mobile network site. + :type site_name: str + :param parameters: Parameters supplied to the create or update mobile network site operation. + :type parameters: ~mobile_network_management_client.models.Site + :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[~mobile_network_management_client.models.Site] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + site_name=site_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Site', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites/{siteName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + site_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Site": + """Updates a site update tags. + + :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 + :param site_name: The name of the mobile network site. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Site, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Site + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Site"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> Iterable["_models.SiteListResult"]: + """Lists all sites in the 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 + :return: An iterator like instance of either SiteListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.SiteListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SiteListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/sites'} # type: ignore 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 new file mode 100644 index 000000000000..6762a8726821 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_slices_operations.py @@ -0,0 +1,673 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}') + 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_-]*$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_mobile_network_request( + subscription_id: str, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class SlicesOperations(object): + """SlicesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~mobile_network_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _delete_initial( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified mobile network slice. + + :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 + :param slice_name: The name of the mobile network slice. + :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + **kwargs: Any + ) -> "_models.Slice": + """Gets information about the specified mobile network slice. + + :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 + :param slice_name: The name of the mobile network slice. + :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) + :rtype: ~mobile_network_management_client.models.Slice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: "_models.Slice", + **kwargs: Any + ) -> "_models.Slice": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Slice') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if response.status_code == 200: + deserialized = self._deserialize('Slice', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Slice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: "_models.Slice", + **kwargs: Any + ) -> LROPoller["_models.Slice"]: + """Creates or updates a mobile network slice. + + :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 + :param slice_name: The name of the mobile network slice. + :type slice_name: str + :param parameters: Parameters supplied to the create or update mobile network slice operation. + :type parameters: ~mobile_network_management_client.models.Slice + :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[~mobile_network_management_client.models.Slice] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + 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._create_or_update_initial( + resource_group_name=resource_group_name, + mobile_network_name=mobile_network_name, + slice_name=slice_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Slice', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices/{sliceName}'} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + mobile_network_name: str, + slice_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.Slice": + """Update slice tags. + + :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 + :param slice_name: The name of the mobile network slice. + :type slice_name: str + :param parameters: Parameters supplied to update mobile network slice tags. + :type parameters: ~mobile_network_management_client.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Slice, or the result of cls(response) + :rtype: ~mobile_network_management_client.models.Slice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Slice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + + @distributed_trace + def list_by_mobile_network( + self, + resource_group_name: str, + mobile_network_name: str, + **kwargs: Any + ) -> Iterable["_models.SliceListResult"]: + """Lists all slices in the 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 + :return: An iterator like instance of either SliceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~mobile_network_management_client.models.SliceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SliceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_mobile_network.metadata['url'], + ) + request = _convert_request(request) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + 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) + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_mobile_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/mobileNetworks/{mobileNetworkName}/slices'} # type: ignore diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/py.typed b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/sdk_packaging.toml b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/sdk_packaging.toml new file mode 100644 index 000000000000..dd1a803d778c --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-mobilenetwork" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Mobilenetwork Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/setup.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/setup.py new file mode 100644 index 000000000000..257f26a81623 --- /dev/null +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/setup.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-mobilenetwork" +PACKAGE_PPRINT_NAME = "Mobilenetwork Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + "Programming Language :: Python :: 3 :: Only", + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/mobilenetwork/ci.yml b/sdk/mobilenetwork/ci.yml new file mode 100644 index 000000000000..98bfa0548ced --- /dev/null +++ b/sdk/mobilenetwork/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/mobilenetwork/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/mobilenetwork/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: mobilenetwork + Artifacts: + - name: azure-mgmt-mobilenetwork + safeName: azuremgmtmobilenetwork diff --git a/shared_requirements.txt b/shared_requirements.txt index acb67a83c14a..81e7123afa49 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -292,6 +292,8 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-cosmosdb msrest>=0.6.21 #override azure-mgmt-cosmosdb azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-monitor azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-mobilenetwork msrest>=0.6.21 +#override azure-mgmt-mobilenetwork azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-kusto msrest>=0.6.21 #override azure-mgmt-kusto azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-servicelinker msrest>=0.6.21