diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json index 5eea24678c70..ebf3383a5482 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/_meta.json @@ -1,11 +1,11 @@ { - "commit": "fb1cc37993d7c2e27669854c1039d913461b5e33", + "commit": "deda40e5c3ef0e10113c02919041effc1654d663", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ "@autorest/python@6.2.7", "@autorest/modelerfour@4.24.3" ], - "autorest_command": "autorest specification/mobilenetwork/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/mobilenetwork/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/mobilenetwork/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py index 11aef5196d36..f1b81f422b37 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_mobile_network_management_client.py @@ -20,13 +20,11 @@ DataNetworksOperations, MobileNetworksOperations, Operations, - PacketCoreControlPlaneOperations, PacketCoreControlPlaneVersionsOperations, PacketCoreControlPlanesOperations, PacketCoreDataPlanesOperations, ServicesOperations, SimGroupsOperations, - SimOperations, SimPoliciesOperations, SimsOperations, SitesOperations, @@ -54,9 +52,6 @@ class MobileNetworkManagementClient: # pylint: disable=client-accepts-api-versi :ivar packet_core_control_planes: PacketCoreControlPlanesOperations operations :vartype packet_core_control_planes: azure.mgmt.mobilenetwork.operations.PacketCoreControlPlanesOperations - :ivar packet_core_control_plane: PacketCoreControlPlaneOperations operations - :vartype packet_core_control_plane: - azure.mgmt.mobilenetwork.operations.PacketCoreControlPlaneOperations :ivar packet_core_control_plane_versions: PacketCoreControlPlaneVersionsOperations operations :vartype packet_core_control_plane_versions: azure.mgmt.mobilenetwork.operations.PacketCoreControlPlaneVersionsOperations @@ -67,8 +62,6 @@ class MobileNetworkManagementClient: # pylint: disable=client-accepts-api-versi :vartype services: azure.mgmt.mobilenetwork.operations.ServicesOperations :ivar sims: SimsOperations operations :vartype sims: azure.mgmt.mobilenetwork.operations.SimsOperations - :ivar sim: SimOperations operations - :vartype sim: azure.mgmt.mobilenetwork.operations.SimOperations :ivar sim_groups: SimGroupsOperations operations :vartype sim_groups: azure.mgmt.mobilenetwork.operations.SimGroupsOperations :ivar sim_policies: SimPoliciesOperations operations @@ -115,9 +108,6 @@ def __init__( self.packet_core_control_planes = PacketCoreControlPlanesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.packet_core_control_plane = PacketCoreControlPlaneOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.packet_core_control_plane_versions = PacketCoreControlPlaneVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -126,7 +116,6 @@ def __init__( ) self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.sims = SimsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sim = SimOperations(self._client, self._config, self._serialize, self._deserialize) self.sim_groups = SimGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.sim_policies = SimPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.sites = SitesOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py index b84b0b99ed0e..82a13f3f66d6 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/_mobile_network_management_client.py @@ -20,13 +20,11 @@ DataNetworksOperations, MobileNetworksOperations, Operations, - PacketCoreControlPlaneOperations, PacketCoreControlPlaneVersionsOperations, PacketCoreControlPlanesOperations, PacketCoreDataPlanesOperations, ServicesOperations, SimGroupsOperations, - SimOperations, SimPoliciesOperations, SimsOperations, SitesOperations, @@ -54,9 +52,6 @@ class MobileNetworkManagementClient: # pylint: disable=client-accepts-api-versi :ivar packet_core_control_planes: PacketCoreControlPlanesOperations operations :vartype packet_core_control_planes: azure.mgmt.mobilenetwork.aio.operations.PacketCoreControlPlanesOperations - :ivar packet_core_control_plane: PacketCoreControlPlaneOperations operations - :vartype packet_core_control_plane: - azure.mgmt.mobilenetwork.aio.operations.PacketCoreControlPlaneOperations :ivar packet_core_control_plane_versions: PacketCoreControlPlaneVersionsOperations operations :vartype packet_core_control_plane_versions: azure.mgmt.mobilenetwork.aio.operations.PacketCoreControlPlaneVersionsOperations @@ -67,8 +62,6 @@ class MobileNetworkManagementClient: # pylint: disable=client-accepts-api-versi :vartype services: azure.mgmt.mobilenetwork.aio.operations.ServicesOperations :ivar sims: SimsOperations operations :vartype sims: azure.mgmt.mobilenetwork.aio.operations.SimsOperations - :ivar sim: SimOperations operations - :vartype sim: azure.mgmt.mobilenetwork.aio.operations.SimOperations :ivar sim_groups: SimGroupsOperations operations :vartype sim_groups: azure.mgmt.mobilenetwork.aio.operations.SimGroupsOperations :ivar sim_policies: SimPoliciesOperations operations @@ -115,9 +108,6 @@ def __init__( self.packet_core_control_planes = PacketCoreControlPlanesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.packet_core_control_plane = PacketCoreControlPlaneOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.packet_core_control_plane_versions = PacketCoreControlPlaneVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -126,7 +116,6 @@ def __init__( ) self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.sims = SimsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sim = SimOperations(self._client, self._config, self._serialize, self._deserialize) self.sim_groups = SimGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.sim_policies = SimPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.sites = SitesOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py index 3173a921e4c3..072372a6f784 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/__init__.py @@ -11,12 +11,10 @@ from ._mobile_networks_operations import MobileNetworksOperations from ._operations import Operations from ._packet_core_control_planes_operations import PacketCoreControlPlanesOperations -from ._packet_core_control_plane_operations import PacketCoreControlPlaneOperations from ._packet_core_control_plane_versions_operations import PacketCoreControlPlaneVersionsOperations from ._packet_core_data_planes_operations import PacketCoreDataPlanesOperations from ._services_operations import ServicesOperations from ._sims_operations import SimsOperations -from ._sim_operations import SimOperations from ._sim_groups_operations import SimGroupsOperations from ._sim_policies_operations import SimPoliciesOperations from ._sites_operations import SitesOperations @@ -32,12 +30,10 @@ "MobileNetworksOperations", "Operations", "PacketCoreControlPlanesOperations", - "PacketCoreControlPlaneOperations", "PacketCoreControlPlaneVersionsOperations", "PacketCoreDataPlanesOperations", "ServicesOperations", "SimsOperations", - "SimOperations", "SimGroupsOperations", "SimPoliciesOperations", "SitesOperations", diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_operations.py deleted file mode 100644 index 5047231df3e6..000000000000 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_plane_operations.py +++ /dev/null @@ -1,562 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._packet_core_control_plane_operations import ( - build_collect_diagnostics_package_request, - build_reinstall_request, - build_rollback_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PacketCoreControlPlaneOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mobilenetwork.aio.MobileNetworkManagementClient`'s - :attr:`packet_core_control_plane` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _rollback_initial( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - request = build_rollback_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._rollback_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _rollback_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" - } - - @distributed_trace_async - async def begin_rollback( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Roll back the specified packet core control plane to the previous version, "rollbackVersion". - Multiple consecutive rollbacks are not possible. This action may cause a service outage. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._rollback_initial( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_rollback.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" - } - - async def _reinstall_initial( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - request = build_reinstall_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._reinstall_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _reinstall_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" - } - - @distributed_trace_async - async def begin_reinstall( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Reinstall the specified packet core control plane. This action will remove any transaction - state from the packet core to return it to a known state. This action will cause a service - outage. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reinstall_initial( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_reinstall.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" - } - - async def _collect_diagnostics_package_initial( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], - **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PacketCoreControlPlaneCollectDiagnosticsPackage") - - request = build_collect_diagnostics_package_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._collect_diagnostics_package_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _collect_diagnostics_package_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" - } - - @overload - async def begin_collect_diagnostics_package( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: _models.PacketCoreControlPlaneCollectDiagnosticsPackage, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Collect a diagnostics package for the specified packet core control plane. This action will - upload the diagnostics to a storage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to the packet core control plane collect diagnostics - package operation. Required. - :type parameters: - ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_collect_diagnostics_package( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Collect a diagnostics package for the specified packet core control plane. This action will - upload the diagnostics to a storage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to the packet core control plane collect diagnostics - package operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_collect_diagnostics_package( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Collect a diagnostics package for the specified packet core control plane. This action will - upload the diagnostics to a storage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to the packet core control plane collect diagnostics - package operation. Is either a model type or a IO type. Required. - :type parameters: - ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._collect_diagnostics_package_initial( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_collect_diagnostics_package.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" - } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py index 9816e25ef3f8..409b951b3074 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_packet_core_control_planes_operations.py @@ -32,11 +32,14 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._packet_core_control_planes_operations import ( + build_collect_diagnostics_package_request, build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, + build_reinstall_request, + build_rollback_request, build_update_tags_request, ) @@ -810,3 +813,503 @@ async def get_next(next_link=None): list_by_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes" } + + async def _rollback_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_rollback_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rollback_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _rollback_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + @distributed_trace_async + async def begin_rollback( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Roll back the specified packet core control plane to the previous version, "rollbackVersion". + Multiple consecutive rollbacks are not possible. This action may cause a service outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._rollback_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_rollback.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + async def _reinstall_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_reinstall_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reinstall_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _reinstall_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + @distributed_trace_async + async def begin_reinstall( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Reinstall the specified packet core control plane. This action will remove any transaction + state from the packet core to return it to a known state. This action will cause a service + outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reinstall_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_reinstall.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + async def _collect_diagnostics_package_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreControlPlaneCollectDiagnosticsPackage") + + request = build_collect_diagnostics_package_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._collect_diagnostics_package_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _collect_diagnostics_package_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } + + @overload + async def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: _models.PacketCoreControlPlaneCollectDiagnosticsPackage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._collect_diagnostics_package_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_collect_diagnostics_package.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_operations.py deleted file mode 100644 index 9e3fec128b01..000000000000 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sim_operations.py +++ /dev/null @@ -1,742 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._sim_operations import ( - build_bulk_delete_request, - build_bulk_upload_encrypted_request, - build_bulk_upload_request, -) - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SimOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mobilenetwork.aio.MobileNetworkManagementClient`'s - :attr:`sim` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _bulk_upload_initial( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SimUploadList") - - request = build_bulk_upload_request( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._bulk_upload_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _bulk_upload_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" - } - - @overload - async def begin_bulk_upload( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.SimUploadList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs to a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM upload operation. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_bulk_upload( - self, - resource_group_name: str, - sim_group_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs to a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM upload operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_bulk_upload( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs to a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM upload operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._bulk_upload_initial( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_bulk_upload.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" - } - - async def _bulk_delete_initial( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SimDeleteList") - - request = build_bulk_delete_request( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._bulk_delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _bulk_delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" - } - - @overload - async def begin_bulk_delete( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.SimDeleteList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk delete SIMs from a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM delete operation. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_bulk_delete( - self, - resource_group_name: str, - sim_group_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk delete SIMs from a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM delete operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_bulk_delete( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk delete SIMs from a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM delete operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._bulk_delete_initial( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_bulk_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" - } - - async def _bulk_upload_encrypted_initial( - self, - resource_group_name: str, - sim_group_name: str, - parameters: Union[_models.EncryptedSimUploadList, IO], - **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "EncryptedSimUploadList") - - request = build_bulk_upload_encrypted_request( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._bulk_upload_encrypted_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _bulk_upload_encrypted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" - } - - @overload - async def begin_bulk_upload_encrypted( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.EncryptedSimUploadList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_bulk_upload_encrypted( - self, - resource_group_name: str, - sim_group_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_bulk_upload_encrypted( - self, - resource_group_name: str, - sim_group_name: str, - parameters: Union[_models.EncryptedSimUploadList, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the encrypted SIMs upload operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._bulk_upload_encrypted_initial( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_bulk_upload_encrypted.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" - } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py index f8f959f25851..8a48522df159 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/aio/operations/_sims_operations.py @@ -32,6 +32,9 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._sims_operations import ( + build_bulk_delete_request, + build_bulk_upload_encrypted_request, + build_bulk_upload_request, build_create_or_update_request, build_delete_request, build_get_request, @@ -588,3 +591,683 @@ async def get_next(next_link=None): list_by_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims" } + + async def _bulk_upload_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimUploadList") + + request = build_bulk_upload_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + @overload + async def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_bulk_upload( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._bulk_upload_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_bulk_upload.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + async def _bulk_delete_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimDeleteList") + + request = build_bulk_delete_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + @overload + async def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimDeleteList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_bulk_delete( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._bulk_delete_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_bulk_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + async def _bulk_upload_encrypted_initial( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "EncryptedSimUploadList") + + request = build_bulk_upload_encrypted_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_encrypted_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_encrypted_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } + + @overload + async def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.EncryptedSimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AsyncOperationStatus or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._bulk_upload_encrypted_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_bulk_upload_encrypted.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py index 3173a921e4c3..072372a6f784 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/__init__.py @@ -11,12 +11,10 @@ from ._mobile_networks_operations import MobileNetworksOperations from ._operations import Operations from ._packet_core_control_planes_operations import PacketCoreControlPlanesOperations -from ._packet_core_control_plane_operations import PacketCoreControlPlaneOperations from ._packet_core_control_plane_versions_operations import PacketCoreControlPlaneVersionsOperations from ._packet_core_data_planes_operations import PacketCoreDataPlanesOperations from ._services_operations import ServicesOperations from ._sims_operations import SimsOperations -from ._sim_operations import SimOperations from ._sim_groups_operations import SimGroupsOperations from ._sim_policies_operations import SimPoliciesOperations from ._sites_operations import SitesOperations @@ -32,12 +30,10 @@ "MobileNetworksOperations", "Operations", "PacketCoreControlPlanesOperations", - "PacketCoreControlPlaneOperations", "PacketCoreControlPlaneVersionsOperations", "PacketCoreDataPlanesOperations", "ServicesOperations", "SimsOperations", - "SimOperations", "SimGroupsOperations", "SimPoliciesOperations", "SitesOperations", diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_operations.py deleted file mode 100644 index 0b9eb8408ffa..000000000000 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_plane_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_rollback_request( - resource_group_name: str, packet_core_control_plane_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "packetCoreControlPlaneName": _SERIALIZER.url( - "packet_core_control_plane_name", - packet_core_control_plane_name, - "str", - max_length=64, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_reinstall_request( - resource_group_name: str, packet_core_control_plane_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "packetCoreControlPlaneName": _SERIALIZER.url( - "packet_core_control_plane_name", - packet_core_control_plane_name, - "str", - max_length=64, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_collect_diagnostics_package_request( - resource_group_name: str, packet_core_control_plane_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "packetCoreControlPlaneName": _SERIALIZER.url( - "packet_core_control_plane_name", - packet_core_control_plane_name, - "str", - max_length=64, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class PacketCoreControlPlaneOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mobilenetwork.MobileNetworkManagementClient`'s - :attr:`packet_core_control_plane` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _rollback_initial( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - request = build_rollback_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._rollback_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _rollback_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" - } - - @distributed_trace - def begin_rollback( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Roll back the specified packet core control plane to the previous version, "rollbackVersion". - Multiple consecutive rollbacks are not possible. This action may cause a service outage. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._rollback_initial( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_rollback.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" - } - - def _reinstall_initial( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - request = build_reinstall_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._reinstall_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _reinstall_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" - } - - @distributed_trace - def begin_reinstall( - self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Reinstall the specified packet core control plane. This action will remove any transaction - state from the packet core to return it to a known state. This action will cause a service - outage. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reinstall_initial( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_reinstall.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" - } - - def _collect_diagnostics_package_initial( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], - **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PacketCoreControlPlaneCollectDiagnosticsPackage") - - request = build_collect_diagnostics_package_request( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._collect_diagnostics_package_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _collect_diagnostics_package_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" - } - - @overload - def begin_collect_diagnostics_package( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: _models.PacketCoreControlPlaneCollectDiagnosticsPackage, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Collect a diagnostics package for the specified packet core control plane. This action will - upload the diagnostics to a storage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to the packet core control plane collect diagnostics - package operation. Required. - :type parameters: - ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_collect_diagnostics_package( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Collect a diagnostics package for the specified packet core control plane. This action will - upload the diagnostics to a storage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to the packet core control plane collect diagnostics - package operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_collect_diagnostics_package( - self, - resource_group_name: str, - packet_core_control_plane_name: str, - parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Collect a diagnostics package for the specified packet core control plane. This action will - upload the diagnostics to a storage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param packet_core_control_plane_name: The name of the packet core control plane. Required. - :type packet_core_control_plane_name: str - :param parameters: Parameters supplied to the packet core control plane collect diagnostics - package operation. Is either a model type or a IO type. Required. - :type parameters: - ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._collect_diagnostics_package_initial( - resource_group_name=resource_group_name, - packet_core_control_plane_name=packet_core_control_plane_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_collect_diagnostics_package.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" - } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py index a1477ad93b45..e32e6119b376 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_packet_core_control_planes_operations.py @@ -261,6 +261,126 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_rollback_request( + resource_group_name: str, packet_core_control_plane_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reinstall_request( + resource_group_name: str, packet_core_control_plane_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_collect_diagnostics_package_request( + resource_group_name: str, packet_core_control_plane_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "packetCoreControlPlaneName": _SERIALIZER.url( + "packet_core_control_plane_name", + packet_core_control_plane_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class PacketCoreControlPlanesOperations: """ .. warning:: @@ -1017,3 +1137,498 @@ def get_next(next_link=None): list_by_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes" } + + def _rollback_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_rollback_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rollback_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _rollback_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + @distributed_trace + def begin_rollback( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Roll back the specified packet core control plane to the previous version, "rollbackVersion". + Multiple consecutive rollbacks are not possible. This action may cause a service outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._rollback_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_rollback.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/rollback" + } + + def _reinstall_initial( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + request = build_reinstall_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reinstall_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _reinstall_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + @distributed_trace + def begin_reinstall( + self, resource_group_name: str, packet_core_control_plane_name: str, **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Reinstall the specified packet core control plane. This action will remove any transaction + state from the packet core to return it to a known state. This action will cause a service + outage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reinstall_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_reinstall.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/reinstall" + } + + def _collect_diagnostics_package_initial( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PacketCoreControlPlaneCollectDiagnosticsPackage") + + request = build_collect_diagnostics_package_request( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._collect_diagnostics_package_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _collect_diagnostics_package_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } + + @overload + def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: _models.PacketCoreControlPlaneCollectDiagnosticsPackage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_collect_diagnostics_package( + self, + resource_group_name: str, + packet_core_control_plane_name: str, + parameters: Union[_models.PacketCoreControlPlaneCollectDiagnosticsPackage, IO], + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Collect a diagnostics package for the specified packet core control plane. This action will + upload the diagnostics to a storage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param packet_core_control_plane_name: The name of the packet core control plane. Required. + :type packet_core_control_plane_name: str + :param parameters: Parameters supplied to the packet core control plane collect diagnostics + package operation. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.mobilenetwork.models.PacketCoreControlPlaneCollectDiagnosticsPackage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._collect_diagnostics_package_initial( + resource_group_name=resource_group_name, + packet_core_control_plane_name=packet_core_control_plane_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_collect_diagnostics_package.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/collectDiagnosticsPackage" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_operations.py deleted file mode 100644 index 7df28e3a708a..000000000000 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sim_operations.py +++ /dev/null @@ -1,846 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_bulk_upload_request( - resource_group_name: str, sim_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "simGroupName": _SERIALIZER.url( - "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_bulk_delete_request( - resource_group_name: str, sim_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "simGroupName": _SERIALIZER.url( - "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_bulk_upload_encrypted_request( - resource_group_name: str, sim_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "simGroupName": _SERIALIZER.url( - "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class SimOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mobilenetwork.MobileNetworkManagementClient`'s - :attr:`sim` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _bulk_upload_initial( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SimUploadList") - - request = build_bulk_upload_request( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._bulk_upload_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _bulk_upload_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" - } - - @overload - def begin_bulk_upload( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.SimUploadList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs to a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM upload operation. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_bulk_upload( - self, - resource_group_name: str, - sim_group_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs to a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM upload operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_bulk_upload( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs to a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM upload operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._bulk_upload_initial( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_bulk_upload.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" - } - - def _bulk_delete_initial( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SimDeleteList") - - request = build_bulk_delete_request( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._bulk_delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _bulk_delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" - } - - @overload - def begin_bulk_delete( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.SimDeleteList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk delete SIMs from a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM delete operation. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_bulk_delete( - self, - resource_group_name: str, - sim_group_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk delete SIMs from a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM delete operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_bulk_delete( - self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk delete SIMs from a SIM group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the bulk SIM delete operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._bulk_delete_initial( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_bulk_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" - } - - def _bulk_upload_encrypted_initial( - self, - resource_group_name: str, - sim_group_name: str, - parameters: Union[_models.EncryptedSimUploadList, IO], - **kwargs: Any - ) -> Optional[_models.AsyncOperationStatus]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "EncryptedSimUploadList") - - request = build_bulk_upload_encrypted_request( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._bulk_upload_encrypted_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _bulk_upload_encrypted_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" - } - - @overload - def begin_bulk_upload_encrypted( - self, - resource_group_name: str, - sim_group_name: str, - parameters: _models.EncryptedSimUploadList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_bulk_upload_encrypted( - self, - resource_group_name: str, - sim_group_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_bulk_upload_encrypted( - self, - resource_group_name: str, - sim_group_name: str, - parameters: Union[_models.EncryptedSimUploadList, IO], - **kwargs: Any - ) -> LROPoller[_models.AsyncOperationStatus]: - """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param sim_group_name: The name of the SIM Group. Required. - :type sim_group_name: str - :param parameters: Parameters supplied to the encrypted SIMs upload operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-11-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._bulk_upload_encrypted_initial( - resource_group_name=resource_group_name, - sim_group_name=sim_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_bulk_upload_encrypted.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" - } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py index 87fcd7093275..920c1ac25a53 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/azure/mgmt/mobilenetwork/operations/_sims_operations.py @@ -189,6 +189,120 @@ def build_list_by_group_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_bulk_upload_request( + resource_group_name: str, sim_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_bulk_delete_request( + resource_group_name: str, sim_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_bulk_upload_encrypted_request( + resource_group_name: str, sim_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "simGroupName": _SERIALIZER.url( + "sim_group_name", sim_group_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class SimsOperations: """ .. warning:: @@ -728,3 +842,674 @@ def get_next(next_link=None): list_by_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/sims" } + + def _bulk_upload_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimUploadList") + + request = build_bulk_upload_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + @overload + def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_bulk_upload( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_bulk_upload( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimUploadList, IO], **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs to a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM upload operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimUploadList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._bulk_upload_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_bulk_upload.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadSims" + } + + def _bulk_delete_initial( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SimDeleteList") + + request = build_bulk_delete_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + @overload + def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.SimDeleteList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_bulk_delete( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_bulk_delete( + self, resource_group_name: str, sim_group_name: str, parameters: Union[_models.SimDeleteList, IO], **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk delete SIMs from a SIM group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the bulk SIM delete operation. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.SimDeleteList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._bulk_delete_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_bulk_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/deleteSims" + } + + def _bulk_upload_encrypted_initial( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> Optional[_models.AsyncOperationStatus]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.AsyncOperationStatus]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "EncryptedSimUploadList") + + request = build_bulk_upload_encrypted_request( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._bulk_upload_encrypted_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _bulk_upload_encrypted_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } + + @overload + def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: _models.EncryptedSimUploadList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_bulk_upload_encrypted( + self, + resource_group_name: str, + sim_group_name: str, + parameters: Union[_models.EncryptedSimUploadList, IO], + **kwargs: Any + ) -> LROPoller[_models.AsyncOperationStatus]: + """Bulk upload SIMs in encrypted form to a SIM group. The SIM credentials must be encrypted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param sim_group_name: The name of the SIM Group. Required. + :type sim_group_name: str + :param parameters: Parameters supplied to the encrypted SIMs upload operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.mobilenetwork.models.EncryptedSimUploadList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AsyncOperationStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mobilenetwork.models.AsyncOperationStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AsyncOperationStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._bulk_upload_encrypted_initial( + resource_group_name=resource_group_name, + sim_group_name=sim_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AsyncOperationStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_bulk_upload_encrypted.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/simGroups/{simGroupName}/uploadEncryptedSims" + } diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_collect_diagnostics_package.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_collect_diagnostics_package.py index f12ed92c7bf4..2c5e324cad09 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_collect_diagnostics_package.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_collect_diagnostics_package.py @@ -29,7 +29,7 @@ def main(): subscription_id="subid", ) - response = client.packet_core_control_plane.begin_collect_diagnostics_package( + response = client.packet_core_control_planes.begin_collect_diagnostics_package( resource_group_name="rg1", packet_core_control_plane_name="TestPacketCoreCP", parameters={ diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_reinstall.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_reinstall.py index c9c09667f10c..b7d19822436e 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_reinstall.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_reinstall.py @@ -29,7 +29,7 @@ def main(): subscription_id="subid", ) - response = client.packet_core_control_plane.begin_reinstall( + response = client.packet_core_control_planes.begin_reinstall( resource_group_name="rg1", packet_core_control_plane_name="TestPacketCoreCP", ).result() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_rollback.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_rollback.py index e74d736a73fb..a0b8fc36772c 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_rollback.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/packet_core_control_plane_rollback.py @@ -29,7 +29,7 @@ def main(): subscription_id="subid", ) - response = client.packet_core_control_plane.begin_rollback( + response = client.packet_core_control_planes.begin_rollback( resource_group_name="rg1", packet_core_control_plane_name="TestPacketCoreCP", ).result() diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_delete.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_delete.py index 2f76a3805a54..510baee3b72f 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_delete.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_delete.py @@ -29,7 +29,7 @@ def main(): subscription_id="subid", ) - response = client.sim.begin_bulk_delete( + response = client.sims.begin_bulk_delete( resource_group_name="testResourceGroupName", sim_group_name="testSimGroup", parameters={"sims": ["testSim", "testSim2"]}, diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload.py index 299d046dc50e..daa807a3fd00 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload.py @@ -29,7 +29,7 @@ def main(): subscription_id="subid", ) - response = client.sim.begin_bulk_upload( + response = client.sims.begin_bulk_upload( resource_group_name="rg1", sim_group_name="testSimGroup", parameters={ diff --git a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload_encrypted.py b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload_encrypted.py index f5304c45a0ea..11a7c4169dea 100644 --- a/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload_encrypted.py +++ b/sdk/mobilenetwork/azure-mgmt-mobilenetwork/generated_samples/sim_bulk_upload_encrypted.py @@ -29,7 +29,7 @@ def main(): subscription_id="subid", ) - response = client.sim.begin_bulk_upload_encrypted( + response = client.sims.begin_bulk_upload_encrypted( resource_group_name="rg1", sim_group_name="testSimGroup", parameters={