From ab7cf957544ab448bcadfdf066ee47a2d32a1f46 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 4 Aug 2022 02:37:42 +0000 Subject: [PATCH] CodeGen from PR 19966 in Azure/azure-rest-api-specs add x-ms-identifiers for hybridnetwork (#19966) --- .../azure-mgmt-hybridnetwork/_meta.json | 10 +- .../azure/mgmt/hybridnetwork/__init__.py | 12 +- .../mgmt/hybridnetwork/_configuration.py | 28 +- .../_hybrid_network_management_client.py | 160 +- .../azure/mgmt/hybridnetwork/_metadata.json | 112 - .../azure/mgmt/hybridnetwork/_patch.py | 19 + .../azure/mgmt/hybridnetwork/_vendor.py | 27 + .../azure/mgmt/hybridnetwork/_version.py | 2 +- .../azure/mgmt/hybridnetwork/aio/__init__.py | 10 + .../mgmt/hybridnetwork/aio/_configuration.py | 15 +- .../aio/_hybrid_network_management_client.py | 148 +- .../azure/mgmt/hybridnetwork/aio/_patch.py | 19 + .../hybridnetwork/aio/operations/__init__.py | 17 +- .../aio/operations/_devices_operations.py | 606 +++--- ...network_function_vendor_skus_operations.py | 197 +- .../_network_function_vendors_operations.py | 114 +- .../_network_functions_operations.py | 684 +++--- .../aio/operations/_operations.py | 105 +- .../hybridnetwork/aio/operations/_patch.py | 19 + .../operations/_role_instances_operations.py | 502 +++-- .../_vendor_network_functions_operations.py | 321 +-- .../_vendor_sku_preview_operations.py | 417 ++-- .../aio/operations/_vendor_skus_operations.py | 466 ++-- .../aio/operations/_vendors_operations.py | 389 ++-- .../mgmt/hybridnetwork/models/__init__.py | 178 +- ..._hybrid_network_management_client_enums.py | 82 +- .../mgmt/hybridnetwork/models/_models.py | 1872 ----------------- .../mgmt/hybridnetwork/models/_models_py3.py | 1492 +++++++++---- .../azure/mgmt/hybridnetwork/models/_patch.py | 19 + .../mgmt/hybridnetwork/operations/__init__.py | 17 +- .../operations/_devices_operations.py | 945 ++++++--- ...network_function_vendor_skus_operations.py | 288 ++- .../_network_function_vendors_operations.py | 165 +- .../_network_functions_operations.py | 1029 ++++++--- .../hybridnetwork/operations/_operations.py | 141 +- .../mgmt/hybridnetwork/operations/_patch.py | 19 + .../operations/_role_instances_operations.py | 817 ++++--- .../_vendor_network_functions_operations.py | 497 +++-- .../_vendor_sku_preview_operations.py | 647 ++++-- .../operations/_vendor_skus_operations.py | 711 +++++-- .../operations/_vendors_operations.py | 577 +++-- 41 files changed, 7679 insertions(+), 6216 deletions(-) delete mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_metadata.json create mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_patch.py create mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_vendor.py create mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_patch.py create mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_patch.py delete mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models.py create mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_patch.py create mode 100644 sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_patch.py diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/_meta.json b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/_meta.json index 34b436418a74..660b5350d120 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/_meta.json +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "a2d4dc4b1296624eefd4b5c235d56af46f7c39d2", + "commit": "66fcf8b0d60a8d869ac06d6b804a7fbca52d9d28", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/hybridnetwork/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/hybridnetwork/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/hybridnetwork/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/__init__.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/__init__.py index 407450606060..936a525a60fd 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/__init__.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['HybridNetworkManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['HybridNetworkManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_configuration.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_configuration.py index 97abf904c8dd..32e42d25cebb 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_configuration.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class HybridNetworkManagementClientConfiguration(Configuration): +class HybridNetworkManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for HybridNetworkManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class HybridNetworkManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(HybridNetworkManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(HybridNetworkManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-05-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-hybridnetwork/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_hybrid_network_management_client.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_hybrid_network_management_client.py index 13b9fa8037e4..5a1b9d5a01ca 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_hybrid_network_management_client.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_hybrid_network_management_client.py @@ -6,119 +6,133 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import HybridNetworkManagementClientConfiguration -from .operations import NetworkFunctionsOperations -from .operations import DevicesOperations -from .operations import Operations -from .operations import VendorsOperations -from .operations import VendorSkusOperations -from .operations import VendorSkuPreviewOperations -from .operations import NetworkFunctionVendorsOperations -from .operations import NetworkFunctionVendorSkusOperations -from .operations import VendorNetworkFunctionsOperations -from .operations import RoleInstancesOperations from . import models +from ._configuration import HybridNetworkManagementClientConfiguration +from .operations import DevicesOperations, NetworkFunctionVendorSkusOperations, NetworkFunctionVendorsOperations, NetworkFunctionsOperations, Operations, RoleInstancesOperations, VendorNetworkFunctionsOperations, VendorSkuPreviewOperations, VendorSkusOperations, VendorsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class HybridNetworkManagementClient(object): - """The definitions in this swagger specification will be used to manage the Hybrid Network resources. +class HybridNetworkManagementClient: # pylint: disable=too-many-instance-attributes + """The definitions in this swagger specification will be used to manage the Hybrid Network + resources. - :ivar network_functions: NetworkFunctionsOperations operations - :vartype network_functions: hybrid_network_management_client.operations.NetworkFunctionsOperations :ivar devices: DevicesOperations operations - :vartype devices: hybrid_network_management_client.operations.DevicesOperations + :vartype devices: azure.mgmt.hybridnetwork.operations.DevicesOperations + :ivar network_functions: NetworkFunctionsOperations operations + :vartype network_functions: azure.mgmt.hybridnetwork.operations.NetworkFunctionsOperations + :ivar network_function_vendors: NetworkFunctionVendorsOperations operations + :vartype network_function_vendors: + azure.mgmt.hybridnetwork.operations.NetworkFunctionVendorsOperations + :ivar network_function_vendor_skus: NetworkFunctionVendorSkusOperations operations + :vartype network_function_vendor_skus: + azure.mgmt.hybridnetwork.operations.NetworkFunctionVendorSkusOperations :ivar operations: Operations operations - :vartype operations: hybrid_network_management_client.operations.Operations + :vartype operations: azure.mgmt.hybridnetwork.operations.Operations :ivar vendors: VendorsOperations operations - :vartype vendors: hybrid_network_management_client.operations.VendorsOperations + :vartype vendors: azure.mgmt.hybridnetwork.operations.VendorsOperations :ivar vendor_skus: VendorSkusOperations operations - :vartype vendor_skus: hybrid_network_management_client.operations.VendorSkusOperations + :vartype vendor_skus: azure.mgmt.hybridnetwork.operations.VendorSkusOperations :ivar vendor_sku_preview: VendorSkuPreviewOperations operations - :vartype vendor_sku_preview: hybrid_network_management_client.operations.VendorSkuPreviewOperations - :ivar network_function_vendors: NetworkFunctionVendorsOperations operations - :vartype network_function_vendors: hybrid_network_management_client.operations.NetworkFunctionVendorsOperations - :ivar network_function_vendor_skus: NetworkFunctionVendorSkusOperations operations - :vartype network_function_vendor_skus: hybrid_network_management_client.operations.NetworkFunctionVendorSkusOperations + :vartype vendor_sku_preview: azure.mgmt.hybridnetwork.operations.VendorSkuPreviewOperations :ivar vendor_network_functions: VendorNetworkFunctionsOperations operations - :vartype vendor_network_functions: hybrid_network_management_client.operations.VendorNetworkFunctionsOperations + :vartype vendor_network_functions: + azure.mgmt.hybridnetwork.operations.VendorNetworkFunctionsOperations :ivar role_instances: RoleInstancesOperations operations - :vartype role_instances: hybrid_network_management_client.operations.RoleInstancesOperations + :vartype role_instances: azure.mgmt.hybridnetwork.operations.RoleInstancesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = HybridNetworkManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = HybridNetworkManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.network_functions = NetworkFunctionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.network_functions = NetworkFunctionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_function_vendors = NetworkFunctionVendorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_function_vendor_skus = NetworkFunctionVendorSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendors = VendorsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendor_skus = VendorSkusOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendor_sku_preview = VendorSkuPreviewOperations( - self._client, self._config, self._serialize, self._deserialize) - self.network_function_vendors = NetworkFunctionVendorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.network_function_vendor_skus = NetworkFunctionVendorSkusOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendor_network_functions = VendorNetworkFunctionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_instances = RoleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_metadata.json b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_metadata.json deleted file mode 100644 index cc752867493e..000000000000 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2021-05-01", - "total_api_version_list": ["2021-05-01"], - "client": { - "name": "HybridNetworkManagementClient", - "filename": "_hybrid_network_management_client", - "description": "The definitions in this swagger specification will be used to manage the Hybrid Network resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"HybridNetworkManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"HybridNetworkManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "network_functions": "NetworkFunctionsOperations", - "devices": "DevicesOperations", - "operations": "Operations", - "vendors": "VendorsOperations", - "vendor_skus": "VendorSkusOperations", - "vendor_sku_preview": "VendorSkuPreviewOperations", - "network_function_vendors": "NetworkFunctionVendorsOperations", - "network_function_vendor_skus": "NetworkFunctionVendorSkusOperations", - "vendor_network_functions": "VendorNetworkFunctionsOperations", - "role_instances": "RoleInstancesOperations" - } -} \ No newline at end of file diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_patch.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_vendor.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_version.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_version.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/_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/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/__init__.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/__init__.py index 99f1c4cfca03..587261d0d4c9 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/__init__.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/__init__.py @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._hybrid_network_management_client import HybridNetworkManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['HybridNetworkManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_configuration.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_configuration.py index d6d635cd522a..4c6c22ec9c0c 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_configuration.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class HybridNetworkManagementClientConfiguration(Configuration): +class HybridNetworkManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for HybridNetworkManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class HybridNetworkManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(HybridNetworkManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(HybridNetworkManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-05-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-hybridnetwork/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_hybrid_network_management_client.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_hybrid_network_management_client.py index 46119263a569..ff607b7ae60d 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_hybrid_network_management_client.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_hybrid_network_management_client.py @@ -6,115 +6,133 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import HybridNetworkManagementClientConfiguration -from .operations import NetworkFunctionsOperations -from .operations import DevicesOperations -from .operations import Operations -from .operations import VendorsOperations -from .operations import VendorSkusOperations -from .operations import VendorSkuPreviewOperations -from .operations import NetworkFunctionVendorsOperations -from .operations import NetworkFunctionVendorSkusOperations -from .operations import VendorNetworkFunctionsOperations -from .operations import RoleInstancesOperations from .. import models +from ._configuration import HybridNetworkManagementClientConfiguration +from .operations import DevicesOperations, NetworkFunctionVendorSkusOperations, NetworkFunctionVendorsOperations, NetworkFunctionsOperations, Operations, RoleInstancesOperations, VendorNetworkFunctionsOperations, VendorSkuPreviewOperations, VendorSkusOperations, VendorsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class HybridNetworkManagementClient(object): - """The definitions in this swagger specification will be used to manage the Hybrid Network resources. +class HybridNetworkManagementClient: # pylint: disable=too-many-instance-attributes + """The definitions in this swagger specification will be used to manage the Hybrid Network + resources. - :ivar network_functions: NetworkFunctionsOperations operations - :vartype network_functions: hybrid_network_management_client.aio.operations.NetworkFunctionsOperations :ivar devices: DevicesOperations operations - :vartype devices: hybrid_network_management_client.aio.operations.DevicesOperations + :vartype devices: azure.mgmt.hybridnetwork.aio.operations.DevicesOperations + :ivar network_functions: NetworkFunctionsOperations operations + :vartype network_functions: azure.mgmt.hybridnetwork.aio.operations.NetworkFunctionsOperations + :ivar network_function_vendors: NetworkFunctionVendorsOperations operations + :vartype network_function_vendors: + azure.mgmt.hybridnetwork.aio.operations.NetworkFunctionVendorsOperations + :ivar network_function_vendor_skus: NetworkFunctionVendorSkusOperations operations + :vartype network_function_vendor_skus: + azure.mgmt.hybridnetwork.aio.operations.NetworkFunctionVendorSkusOperations :ivar operations: Operations operations - :vartype operations: hybrid_network_management_client.aio.operations.Operations + :vartype operations: azure.mgmt.hybridnetwork.aio.operations.Operations :ivar vendors: VendorsOperations operations - :vartype vendors: hybrid_network_management_client.aio.operations.VendorsOperations + :vartype vendors: azure.mgmt.hybridnetwork.aio.operations.VendorsOperations :ivar vendor_skus: VendorSkusOperations operations - :vartype vendor_skus: hybrid_network_management_client.aio.operations.VendorSkusOperations + :vartype vendor_skus: azure.mgmt.hybridnetwork.aio.operations.VendorSkusOperations :ivar vendor_sku_preview: VendorSkuPreviewOperations operations - :vartype vendor_sku_preview: hybrid_network_management_client.aio.operations.VendorSkuPreviewOperations - :ivar network_function_vendors: NetworkFunctionVendorsOperations operations - :vartype network_function_vendors: hybrid_network_management_client.aio.operations.NetworkFunctionVendorsOperations - :ivar network_function_vendor_skus: NetworkFunctionVendorSkusOperations operations - :vartype network_function_vendor_skus: hybrid_network_management_client.aio.operations.NetworkFunctionVendorSkusOperations + :vartype vendor_sku_preview: azure.mgmt.hybridnetwork.aio.operations.VendorSkuPreviewOperations :ivar vendor_network_functions: VendorNetworkFunctionsOperations operations - :vartype vendor_network_functions: hybrid_network_management_client.aio.operations.VendorNetworkFunctionsOperations + :vartype vendor_network_functions: + azure.mgmt.hybridnetwork.aio.operations.VendorNetworkFunctionsOperations :ivar role_instances: RoleInstancesOperations operations - :vartype role_instances: hybrid_network_management_client.aio.operations.RoleInstancesOperations + :vartype role_instances: azure.mgmt.hybridnetwork.aio.operations.RoleInstancesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = HybridNetworkManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = HybridNetworkManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.network_functions = NetworkFunctionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.network_functions = NetworkFunctionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_function_vendors = NetworkFunctionVendorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_function_vendor_skus = NetworkFunctionVendorSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendors = VendorsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendor_skus = VendorSkusOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendor_sku_preview = VendorSkuPreviewOperations( - self._client, self._config, self._serialize, self._deserialize) - self.network_function_vendors = NetworkFunctionVendorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.network_function_vendor_skus = NetworkFunctionVendorSkusOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.vendor_network_functions = VendorNetworkFunctionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_instances = RoleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_patch.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/__init__.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/__init__.py index ff21fc7723ce..0063fdc1cad4 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/__init__.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/__init__.py @@ -6,26 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._network_functions_operations import NetworkFunctionsOperations from ._devices_operations import DevicesOperations +from ._network_functions_operations import NetworkFunctionsOperations +from ._network_function_vendors_operations import NetworkFunctionVendorsOperations +from ._network_function_vendor_skus_operations import NetworkFunctionVendorSkusOperations from ._operations import Operations from ._vendors_operations import VendorsOperations from ._vendor_skus_operations import VendorSkusOperations from ._vendor_sku_preview_operations import VendorSkuPreviewOperations -from ._network_function_vendors_operations import NetworkFunctionVendorsOperations -from ._network_function_vendor_skus_operations import NetworkFunctionVendorSkusOperations from ._vendor_network_functions_operations import VendorNetworkFunctionsOperations from ._role_instances_operations import RoleInstancesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'NetworkFunctionsOperations', 'DevicesOperations', + 'NetworkFunctionsOperations', + 'NetworkFunctionVendorsOperations', + 'NetworkFunctionVendorSkusOperations', 'Operations', 'VendorsOperations', 'VendorSkusOperations', 'VendorSkuPreviewOperations', - 'NetworkFunctionVendorsOperations', - 'NetworkFunctionVendorSkusOperations', 'VendorNetworkFunctionsOperations', 'RoleInstancesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_devices_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_devices_operations.py index df2be78e7a6b..917eb3f0d8dd 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_devices_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,95 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._devices_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_registration_key_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DevicesOperations: - """DevicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, device_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, device_name: str, @@ -102,44 +108,52 @@ async def begin_delete( :type device_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, device_name=device_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -148,16 +162,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, device_name: str, **kwargs: Any - ) -> "_models.Device": + ) -> _models.Device: """Gets information about the specified device. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -166,41 +181,43 @@ async def get( :type device_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Device, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.Device + :rtype: ~azure.mgmt.hybridnetwork.models.Device :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] + + + request = build_get_request( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Device', pipeline_response) @@ -209,53 +226,55 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, device_name: str, - parameters: "_models.Device", + parameters: _models.Device, **kwargs: Any - ) -> "_models.Device": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] + ) -> _models.Device: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Device') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] + + _json = self._serialize.body(parameters, 'Device') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Device', pipeline_response) @@ -267,15 +286,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, device_name: str, - parameters: "_models.Device", + parameters: _models.Device, **kwargs: Any - ) -> AsyncLROPoller["_models.Device"]: + ) -> AsyncLROPoller[_models.Device]: """Creates or updates a device. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -283,51 +305,61 @@ async def begin_create_or_update( :param device_name: Resource name for the device resource. :type device_name: str :param parameters: Parameters supplied to the create or update device operation. - :type parameters: ~hybrid_network_management_client.models.Device + :type parameters: ~azure.mgmt.hybridnetwork.models.Device :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. + :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 Device or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~hybrid_network_management_client.models.Device] - :raises ~azure.core.exceptions.HttpResponseError: + :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 Device or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridnetwork.models.Device] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, device_name=device_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Device', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -336,17 +368,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, device_name: str, - parameters: "_models.TagsObject", + parameters: _models.TagsObject, **kwargs: Any - ) -> "_models.Device": + ) -> _models.Device: """Updates device tags. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -354,49 +387,50 @@ async def update_tags( :param device_name: The name of the device resource. :type device_name: str :param parameters: Parameters supplied to the update device tags operation. - :type parameters: ~hybrid_network_management_client.models.TagsObject + :type parameters: ~azure.mgmt.hybridnetwork.models.TagsObject :keyword callable cls: A custom type or function that will be passed the direct response :return: Device, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.Device + :rtype: ~azure.mgmt.hybridnetwork.models.Device :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Device', pipeline_response) @@ -405,52 +439,62 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + + + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DeviceListResult"]: + ) -> AsyncIterable[_models.DeviceListResult]: """Lists all the devices in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.DeviceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.DeviceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeviceListResult', pipeline_response) + deserialized = self._deserialize("DeviceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -459,69 +503,83 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/devices'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/devices"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DeviceListResult"]: + ) -> AsyncIterable[_models.DeviceListResult]: """Lists all the device resource in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.DeviceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.DeviceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeviceListResult', pipeline_response) + deserialized = self._deserialize("DeviceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -530,27 +588,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices"} # type: ignore + @distributed_trace_async async def list_registration_key( self, resource_group_name: str, device_name: str, **kwargs: Any - ) -> "_models.DeviceRegistrationKey": + ) -> _models.DeviceRegistrationKey: """List the registration key for the device. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -559,41 +623,43 @@ async def list_registration_key( :type device_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DeviceRegistrationKey, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.DeviceRegistrationKey + :rtype: ~azure.mgmt.hybridnetwork.models.DeviceRegistrationKey :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceRegistrationKey"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.list_registration_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceRegistrationKey] + + + request = build_list_registration_key_request( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_registration_key.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeviceRegistrationKey', pipeline_response) @@ -602,4 +668,6 @@ async def list_registration_key( return cls(pipeline_response, deserialized, {}) return deserialized - list_registration_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}/listRegistrationKey'} # type: ignore + + list_registration_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}/listRegistrationKey"} # type: ignore + diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendor_skus_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendor_skus_operations.py index 395a0651b598..82164d74ade5 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendor_skus_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendor_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,101 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models - +from ..._vendor import _convert_request +from ...operations._network_function_vendor_skus_operations import build_list_by_sku_request, build_list_by_vendor_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NetworkFunctionVendorSkusOperations: - """NetworkFunctionVendorSkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_function_vendor_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_vendor( self, vendor_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NetworkFunctionSkuListResult"]: + ) -> AsyncIterable[_models.NetworkFunctionSkuListResult]: """Lists all network function vendor sku details in a vendor. :param vendor_name: The name of the network function vendor. :type vendor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionSkuListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.NetworkFunctionSkuListResult] + :return: An iterator like instance of either NetworkFunctionSkuListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_vendor.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_vendor_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_vendor.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_vendor_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionSkuListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,27 +109,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_vendor.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus'} # type: ignore + list_by_vendor.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus"} # type: ignore + @distributed_trace def list_by_sku( self, vendor_name: str, vendor_sku_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NetworkFunctionSkuDetails"]: + ) -> AsyncIterable[_models.NetworkFunctionSkuDetails]: """Lists information about network function vendor sku details. :param vendor_name: The name of the network function vendor. @@ -125,45 +143,55 @@ def list_by_sku( :param vendor_sku_name: The name of the network function sku. :type vendor_sku_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionSkuDetails or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.NetworkFunctionSkuDetails] + :return: An iterator like instance of either NetworkFunctionSkuDetails or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionSkuDetails] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionSkuDetails"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionSkuDetails] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sku.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'vendorSkuName': self._serialize.url("vendor_sku_name", vendor_sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + vendor_name=vendor_name, + vendor_sku_name=vendor_sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_sku.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + vendor_name=vendor_name, + vendor_sku_name=vendor_sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionSkuDetails', pipeline_response) + deserialized = self._deserialize("NetworkFunctionSkuDetails", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,17 +200,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_sku.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus/{vendorSkuName}'} # type: ignore + list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus/{vendorSkuName}"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendors_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendors_operations.py index 5a49d7190195..69839fafc6e8 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendors_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_function_vendors_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models - +from ..._vendor import _convert_request +from ...operations._network_function_vendors_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NetworkFunctionVendorsOperations: - """NetworkFunctionVendorsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_function_vendors` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.NetworkFunctionVendorListResult"]: + ) -> AsyncIterable[_models.NetworkFunctionVendorListResult]: """Lists all the available vendor and sku information. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionVendorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.NetworkFunctionVendorListResult] + :return: An iterator like instance of either NetworkFunctionVendorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionVendorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionVendorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionVendorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionVendorListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionVendorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,17 +104,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_functions_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_functions_operations.py index f0949d3801c7..425503dea6c3 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_functions_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_network_functions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,95 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._network_functions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_execute_request_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NetworkFunctionsOperations: - """NetworkFunctionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_functions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, network_function_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, network_function_name: str, @@ -103,44 +109,52 @@ async def begin_delete( :type network_function_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, network_function_name=network_function_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -149,16 +163,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, network_function_name: str, **kwargs: Any - ) -> "_models.NetworkFunction": + ) -> _models.NetworkFunction: """Gets information about the specified network function resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -167,41 +182,43 @@ async def get( :type network_function_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkFunction, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.NetworkFunction + :rtype: ~azure.mgmt.hybridnetwork.models.NetworkFunction :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] + + + request = build_get_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkFunction', pipeline_response) @@ -210,53 +227,55 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, network_function_name: str, - parameters: "_models.NetworkFunction", + parameters: _models.NetworkFunction, **kwargs: Any - ) -> "_models.NetworkFunction": - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] + ) -> _models.NetworkFunction: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkFunction') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] + + _json = self._serialize.body(parameters, 'NetworkFunction') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('NetworkFunction', pipeline_response) @@ -268,15 +287,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, network_function_name: str, - parameters: "_models.NetworkFunction", + parameters: _models.NetworkFunction, **kwargs: Any - ) -> AsyncLROPoller["_models.NetworkFunction"]: + ) -> AsyncLROPoller[_models.NetworkFunction]: """Creates or updates a network function resource. This operation can take up to 6 hours to complete. This is expected service behavior. @@ -286,51 +308,61 @@ async def begin_create_or_update( :type network_function_name: str :param parameters: Parameters supplied in the body to the create or update network function operation. - :type parameters: ~hybrid_network_management_client.models.NetworkFunction + :type parameters: ~azure.mgmt.hybridnetwork.models.NetworkFunction :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. + :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 NetworkFunction or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~hybrid_network_management_client.models.NetworkFunction] - :raises ~azure.core.exceptions.HttpResponseError: + :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 NetworkFunction or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridnetwork.models.NetworkFunction] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, network_function_name=network_function_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('NetworkFunction', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -339,17 +371,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, network_function_name: str, - parameters: "_models.TagsObject", + parameters: _models.TagsObject, **kwargs: Any - ) -> "_models.NetworkFunction": + ) -> _models.NetworkFunction: """Updates the tags for the network function resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -357,49 +390,50 @@ async def update_tags( :param network_function_name: Resource name for the network function resource. :type network_function_name: str :param parameters: Parameters supplied to the update network function tags operation. - :type parameters: ~hybrid_network_management_client.models.TagsObject + :type parameters: ~azure.mgmt.hybridnetwork.models.TagsObject :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkFunction, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.NetworkFunction + :rtype: ~azure.mgmt.hybridnetwork.models.NetworkFunction :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkFunction', pipeline_response) @@ -408,52 +442,63 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + + + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.NetworkFunctionListResult"]: + ) -> AsyncIterable[_models.NetworkFunctionListResult]: """Lists all the network functions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.NetworkFunctionListResult] + :return: An iterator like instance of either NetworkFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -462,69 +507,84 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctions'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctions"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NetworkFunctionListResult"]: + ) -> AsyncIterable[_models.NetworkFunctionListResult]: """Lists all the network function resources in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.NetworkFunctionListResult] + :return: An iterator like instance of either NetworkFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -533,17 +593,153 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions"} # type: ignore + + async def _execute_request_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.ExecuteRequestParameters, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(parameters, 'ExecuteRequestParameters') + + request = build_execute_request_request_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._execute_request_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _execute_request_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/executeRequest"} # type: ignore + + + @distributed_trace_async + async def begin_execute_request( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.ExecuteRequestParameters, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Execute a request to services on a network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param network_function_name: The name of the network function. + :type network_function_name: str + :param parameters: Payload for execute request post call. + :type parameters: ~azure.mgmt.hybridnetwork.models.ExecuteRequestParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._execute_request_initial( # type: ignore + resource_group_name=resource_group_name, + network_function_name=network_function_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_execute_request.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/executeRequest"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_operations.py index 58f34e8dcf31..34aaa8d58b5f 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,93 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationList"]: + ) -> AsyncIterable[_models.OperationListResult]: """Gets a list of the operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.OperationList] + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +101,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.HybridNetwork/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.HybridNetwork/operations"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_patch.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_role_instances_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_role_instances_operations.py index 2126509c8d91..6435adcfe986 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_role_instances_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_role_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,45 +6,47 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._role_instances_operations import build_get_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleInstancesOperations: - """RoleInstancesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`role_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _start_initial( + + async def _start_initial( # pylint: disable=inconsistent-return-statements self, location_name: str, vendor_name: str, @@ -51,48 +54,51 @@ async def _start_initial( role_instance_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start'} # type: ignore + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start"} # type: ignore - async def begin_start( + + @distributed_trace_async + async def begin_start( # pylint: disable=inconsistent-return-statements self, location_name: str, vendor_name: str, @@ -113,48 +119,54 @@ async def begin_start( :type role_instance_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, role_instance_name=role_instance_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -163,11 +175,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start"} # type: ignore - async def _stop_initial( + async def _stop_initial( # pylint: disable=inconsistent-return-statements self, location_name: str, vendor_name: str, @@ -175,48 +187,51 @@ async def _stop_initial( role_instance_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_stop_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop'} # type: ignore + _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop"} # type: ignore + - async def begin_stop( + @distributed_trace_async + async def begin_stop( # pylint: disable=inconsistent-return-statements self, location_name: str, vendor_name: str, @@ -237,48 +252,54 @@ async def begin_stop( :type role_instance_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, role_instance_name=role_instance_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -287,11 +308,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop"} # type: ignore - async def _restart_initial( + async def _restart_initial( # pylint: disable=inconsistent-return-statements self, location_name: str, vendor_name: str, @@ -299,48 +320,51 @@ async def _restart_initial( role_instance_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._restart_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_restart_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart'} # type: ignore + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart"} # type: ignore - async def begin_restart( + + @distributed_trace_async + async def begin_restart( # pylint: disable=inconsistent-return-statements self, location_name: str, vendor_name: str, @@ -361,48 +385,54 @@ async def begin_restart( :type role_instance_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._restart_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, role_instance_name=role_instance_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -411,10 +441,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart"} # type: ignore + + @distributed_trace_async async def get( self, location_name: str, @@ -422,7 +453,7 @@ async def get( service_key: str, role_instance_name: str, **kwargs: Any - ) -> "_models.RoleInstance": + ) -> _models.RoleInstance: """Gets the information of role instance of vendor network function. :param location_name: The Azure region where the network function resource was created by @@ -436,43 +467,45 @@ async def get( :type role_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleInstance, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.RoleInstance + :rtype: ~azure.mgmt.hybridnetwork.models.RoleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] + + + request = build_get_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleInstance', pipeline_response) @@ -481,15 +514,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}"} # type: ignore + + + @distributed_trace def list( self, location_name: str, vendor_name: str, service_key: str, **kwargs: Any - ) -> AsyncIterable["_models.NetworkFunctionRoleInstanceListResult"]: + ) -> AsyncIterable[_models.NetworkFunctionRoleInstanceListResult]: """Lists the information of role instances of vendor network function. :param location_name: The Azure region where the network function resource was created by @@ -500,46 +536,57 @@ def list( :param service_key: The GUID for the vendor network function. :type service_key: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionRoleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.NetworkFunctionRoleInstanceListResult] + :return: An iterator like instance of either NetworkFunctionRoleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionRoleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionRoleInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionRoleInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionRoleInstanceListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionRoleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -548,17 +595,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_network_functions_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_network_functions_operations.py index 672b2800e48e..c8c6ca9a6395 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_network_functions_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_network_functions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,51 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._vendor_network_functions_operations import build_create_or_update_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VendorNetworkFunctionsOperations: - """VendorNetworkFunctionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`vendor_network_functions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, location_name: str, vendor_name: str, service_key: str, **kwargs: Any - ) -> "_models.VendorNetworkFunction": + ) -> _models.VendorNetworkFunction: """Gets information about the specified vendor network function. :param location_name: The Azure region where the network function resource was created by the @@ -61,42 +65,44 @@ async def get( :type service_key: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VendorNetworkFunction, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.VendorNetworkFunction + :rtype: ~azure.mgmt.hybridnetwork.models.VendorNetworkFunction :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunction"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunction] + + + request = build_get_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VendorNetworkFunction', pipeline_response) @@ -105,55 +111,57 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}"} # type: ignore + async def _create_or_update_initial( self, location_name: str, vendor_name: str, service_key: str, - parameters: "_models.VendorNetworkFunction", + parameters: _models.VendorNetworkFunction, **kwargs: Any - ) -> "_models.VendorNetworkFunction": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunction"] + ) -> _models.VendorNetworkFunction: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VendorNetworkFunction') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunction] + + _json = self._serialize.body(parameters, 'VendorNetworkFunction') + + request = build_create_or_update_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VendorNetworkFunction', pipeline_response) @@ -165,16 +173,19 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, location_name: str, vendor_name: str, service_key: str, - parameters: "_models.VendorNetworkFunction", + parameters: _models.VendorNetworkFunction, **kwargs: Any - ) -> AsyncLROPoller["_models.VendorNetworkFunction"]: + ) -> AsyncLROPoller[_models.VendorNetworkFunction]: """Creates or updates a vendor network function. This operation can take up to 6 hours to complete. This is expected service behavior. @@ -187,53 +198,63 @@ async def begin_create_or_update( :type service_key: str :param parameters: Parameters supplied to the create or update vendor network function operation. - :type parameters: ~hybrid_network_management_client.models.VendorNetworkFunction + :type parameters: ~azure.mgmt.hybridnetwork.models.VendorNetworkFunction :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. + :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 VendorNetworkFunction or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~hybrid_network_management_client.models.VendorNetworkFunction] - :raises ~azure.core.exceptions.HttpResponseError: + :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 VendorNetworkFunction or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridnetwork.models.VendorNetworkFunction] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunction] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunction"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, 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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('VendorNetworkFunction', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -242,17 +263,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}"} # type: ignore + @distributed_trace def list( self, location_name: str, vendor_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VendorNetworkFunctionListResult"]: + ) -> AsyncIterable[_models.VendorNetworkFunctionListResult]: """Lists all the vendor network function sub resources in an Azure region, filtered by skuType, skuName, vendorProvisioningState. @@ -262,50 +284,60 @@ def list( :param vendor_name: The name of the vendor. :type vendor_name: str :param filter: The filter to apply on the operation. The properties you can use for eq (equals) - are: skuType, skuName and vendorProvisioningState. + are: skuType, skuName and vendorProvisioningState. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VendorNetworkFunctionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.VendorNetworkFunctionListResult] + :return: An iterator like instance of either VendorNetworkFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.VendorNetworkFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunctionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunctionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VendorNetworkFunctionListResult', pipeline_response) + deserialized = self._deserialize("VendorNetworkFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,17 +346,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_sku_preview_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_sku_preview_operations.py index f3d633dffaf0..35fde2c9ca87 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_sku_preview_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_sku_preview_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._vendor_sku_preview_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VendorSkuPreviewOperations: - """VendorSkuPreviewOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`vendor_sku_preview` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, vendor_name: str, sku_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PreviewSubscriptionsList"]: + ) -> AsyncIterable[_models.PreviewSubscriptionsList]: """Lists all the preview information of a vendor sku. :param vendor_name: The name of the vendor. @@ -56,45 +60,55 @@ def list( :param sku_name: The name of the sku. :type sku_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PreviewSubscriptionsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.PreviewSubscriptionsList] + :return: An iterator like instance of either PreviewSubscriptionsList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.PreviewSubscriptionsList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscriptionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscriptionsList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PreviewSubscriptionsList', pipeline_response) + deserialized = self._deserialize("PreviewSubscriptionsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,68 +117,73 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions"} # type: ignore async def _create_or_update_initial( self, vendor_name: str, sku_name: str, preview_subscription: str, - parameters: "_models.PreviewSubscription", + parameters: _models.PreviewSubscription, **kwargs: Any - ) -> "_models.PreviewSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscription"] + ) -> _models.PreviewSubscription: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PreviewSubscription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscription] + + _json = self._serialize.body(parameters, 'PreviewSubscription') + + request = build_create_or_update_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + preview_subscription=preview_subscription, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PreviewSubscription', pipeline_response) @@ -176,16 +195,19 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, vendor_name: str, sku_name: str, preview_subscription: str, - parameters: "_models.PreviewSubscription", + parameters: _models.PreviewSubscription, **kwargs: Any - ) -> AsyncLROPoller["_models.PreviewSubscription"]: + ) -> AsyncLROPoller[_models.PreviewSubscription]: """Creates or updates preview information of a vendor sku. :param vendor_name: The name of the vendor. @@ -196,53 +218,63 @@ async def begin_create_or_update( :type preview_subscription: str :param parameters: Parameters supplied to the create or update vendor preview subscription operation. - :type parameters: ~hybrid_network_management_client.models.PreviewSubscription + :type parameters: ~azure.mgmt.hybridnetwork.models.PreviewSubscription :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. + :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 PreviewSubscription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~hybrid_network_management_client.models.PreviewSubscription] - :raises ~azure.core.exceptions.HttpResponseError: + :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 PreviewSubscription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridnetwork.models.PreviewSubscription] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscription] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscription"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_name, preview_subscription=preview_subscription, 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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('PreviewSubscription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -251,17 +283,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore + + @distributed_trace_async async def get( self, vendor_name: str, sku_name: str, preview_subscription: str, **kwargs: Any - ) -> "_models.PreviewSubscription": + ) -> _models.PreviewSubscription: """Gets the preview information of a vendor sku. :param vendor_name: The name of the vendor. @@ -272,42 +305,44 @@ async def get( :type preview_subscription: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PreviewSubscription, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.PreviewSubscription + :rtype: ~azure.mgmt.hybridnetwork.models.PreviewSubscription :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscription] + + + request = build_get_request( + vendor_name=vendor_name, + sku_name=sku_name, + preview_subscription=preview_subscription, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PreviewSubscription', pipeline_response) @@ -316,56 +351,61 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore - async def _delete_initial( + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, vendor_name: str, sku_name: str, preview_subscription: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + preview_subscription=preview_subscription, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, vendor_name: str, sku_name: str, @@ -382,46 +422,53 @@ async def begin_delete( :type preview_subscription: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_name, preview_subscription=preview_subscription, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -430,6 +477,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_skus_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_skus_operations.py index a0a641b4968c..60d539c2ca80 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_skus_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendor_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,95 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._vendor_skus_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_credential_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VendorSkusOperations: - """VendorSkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`vendor_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, vendor_name: str, sku_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, vendor_name: str, sku_name: str, @@ -103,44 +109,52 @@ async def begin_delete( :type sku_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -149,16 +163,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + + @distributed_trace_async async def get( self, vendor_name: str, sku_name: str, **kwargs: Any - ) -> "_models.VendorSku": + ) -> _models.VendorSku: """Gets information about the specified sku. :param vendor_name: The name of the vendor. @@ -167,41 +182,43 @@ async def get( :type sku_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VendorSku, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.VendorSku + :rtype: ~azure.mgmt.hybridnetwork.models.VendorSku :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSku"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSku] + + + request = build_get_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VendorSku', pipeline_response) @@ -210,53 +227,55 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + async def _create_or_update_initial( self, vendor_name: str, sku_name: str, - parameters: "_models.VendorSku", + parameters: _models.VendorSku, **kwargs: Any - ) -> "_models.VendorSku": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSku"] + ) -> _models.VendorSku: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VendorSku') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSku] + + _json = self._serialize.body(parameters, 'VendorSku') + + request = build_create_or_update_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VendorSku', pipeline_response) @@ -268,15 +287,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, vendor_name: str, sku_name: str, - parameters: "_models.VendorSku", + parameters: _models.VendorSku, **kwargs: Any - ) -> AsyncLROPoller["_models.VendorSku"]: + ) -> AsyncLROPoller[_models.VendorSku]: """Creates or updates a sku. This operation can take up to 2 hours to complete. This is expected service behavior. @@ -285,51 +307,61 @@ async def begin_create_or_update( :param sku_name: The name of the sku. :type sku_name: str :param parameters: Parameters supplied to the create or update sku operation. - :type parameters: ~hybrid_network_management_client.models.VendorSku + :type parameters: ~azure.mgmt.hybridnetwork.models.VendorSku :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. + :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 VendorSku or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~hybrid_network_management_client.models.VendorSku] - :raises ~azure.core.exceptions.HttpResponseError: + :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 VendorSku or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridnetwork.models.VendorSku] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSku] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSku"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('VendorSku', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -338,58 +370,67 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + @distributed_trace def list( self, vendor_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VendorSkuListResult"]: + ) -> AsyncIterable[_models.VendorSkuListResult]: """Lists all the skus of a vendor. :param vendor_name: The name of the vendor. :type vendor_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VendorSkuListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.VendorSkuListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.VendorSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VendorSkuListResult', pipeline_response) + deserialized = self._deserialize("VendorSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -398,17 +439,86 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus"} # type: ignore + + @distributed_trace_async + async def list_credential( + self, + vendor_name: str, + sku_name: str, + **kwargs: Any + ) -> _models.SkuCredential: + """Generate credentials for publishing SKU images. + + :param vendor_name: The name of the vendor. + :type vendor_name: str + :param sku_name: The name of the sku. + :type sku_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SkuCredential, or the result of cls(response) + :rtype: ~azure.mgmt.hybridnetwork.models.SkuCredential + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SkuCredential] + + + request = build_list_credential_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credential.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SkuCredential', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credential.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/listCredential"} # type: ignore + diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendors_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendors_operations.py index bc0b76d524dd..2df3a12dff75 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendors_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/aio/operations/_vendors_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,93 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._vendors_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VendorsOperations: - """VendorsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.aio.HybridNetworkManagementClient`'s + :attr:`vendors` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, vendor_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request_initial( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, vendor_name: str, **kwargs: Any @@ -97,42 +103,51 @@ async def begin_delete( :type vendor_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore vendor_name=vendor_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -141,55 +156,58 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + + @distributed_trace_async async def get( self, vendor_name: str, **kwargs: Any - ) -> "_models.Vendor": + ) -> _models.Vendor: """Gets information about the specified vendor. :param vendor_name: The name of the vendor. :type vendor_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Vendor, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.Vendor + :rtype: ~azure.mgmt.hybridnetwork.models.Vendor :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Vendor"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Vendor] + + + request = build_get_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Vendor', pipeline_response) @@ -198,54 +216,56 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + async def _create_or_update_initial( self, vendor_name: str, - parameters: Optional["_models.Vendor"] = None, + parameters: Optional[_models.Vendor] = None, **kwargs: Any - ) -> "_models.Vendor": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Vendor"] + ) -> _models.Vendor: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Vendor] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'Vendor') + _json = self._serialize.body(parameters, 'Vendor') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_create_or_update_request_initial( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Vendor', pipeline_response) @@ -257,62 +277,76 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, vendor_name: str, - parameters: Optional["_models.Vendor"] = None, + parameters: Optional[_models.Vendor] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Vendor"]: + ) -> AsyncLROPoller[_models.Vendor]: """Creates or updates a vendor. :param vendor_name: The name of the vendor. :type vendor_name: str - :param parameters: Parameters supplied to the create vendor operation. - :type parameters: ~hybrid_network_management_client.models.Vendor + :param parameters: Parameters supplied to the create vendor operation. Default value is None. + :type parameters: ~azure.mgmt.hybridnetwork.models.Vendor :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. + :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 Vendor or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~hybrid_network_management_client.models.Vendor] - :raises ~azure.core.exceptions.HttpResponseError: + :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 Vendor or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridnetwork.models.Vendor] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Vendor] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Vendor"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore vendor_name=vendor_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Vendor', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -321,54 +355,62 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.VendorListResult"]: + ) -> AsyncIterable[_models.VendorListResult]: """Lists all the vendors in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VendorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_network_management_client.models.VendorListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridnetwork.models.VendorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VendorListResult', pipeline_response) + deserialized = self._deserialize("VendorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -377,17 +419,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/__init__.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/__init__.py index 0f30a76e4400..8b53989c955a 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/__init__.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/__init__.py @@ -6,121 +6,76 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CustomProfile - from ._models_py3 import DataDisk - from ._models_py3 import Device - from ._models_py3 import DeviceListResult - from ._models_py3 import DevicePropertiesFormat - from ._models_py3 import DeviceRegistrationKey - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import ImageReference - from ._models_py3 import LinuxConfiguration - from ._models_py3 import NetworkFunction - from ._models_py3 import NetworkFunctionListResult - from ._models_py3 import NetworkFunctionRoleConfiguration - from ._models_py3 import NetworkFunctionRoleInstanceListResult - from ._models_py3 import NetworkFunctionSkuDetails - from ._models_py3 import NetworkFunctionSkuListResult - from ._models_py3 import NetworkFunctionSkuRoleDetails - from ._models_py3 import NetworkFunctionTemplate - from ._models_py3 import NetworkFunctionUserConfiguration - from ._models_py3 import NetworkFunctionUserConfigurationOsProfile - from ._models_py3 import NetworkFunctionVendor - from ._models_py3 import NetworkFunctionVendorConfiguration - from ._models_py3 import NetworkFunctionVendorListResult - from ._models_py3 import NetworkInterface - from ._models_py3 import NetworkInterfaceIPConfiguration - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import OsDisk - from ._models_py3 import OsProfile - from ._models_py3 import PreviewSubscription - from ._models_py3 import PreviewSubscriptionsList - from ._models_py3 import ProxyResource - from ._models_py3 import Resource - from ._models_py3 import RoleInstance - from ._models_py3 import SkuOverview - from ._models_py3 import SshConfiguration - from ._models_py3 import SshPublicKey - from ._models_py3 import StorageProfile - from ._models_py3 import SubResource - from ._models_py3 import SystemData - from ._models_py3 import TagsObject - from ._models_py3 import TrackedResource - from ._models_py3 import Vendor - from ._models_py3 import VendorListResult - from ._models_py3 import VendorNetworkFunction - from ._models_py3 import VendorNetworkFunctionListResult - from ._models_py3 import VendorSku - from ._models_py3 import VendorSkuListResult - from ._models_py3 import VirtualHardDisk -except (SyntaxError, ImportError): - from ._models import CustomProfile # type: ignore - from ._models import DataDisk # type: ignore - from ._models import Device # type: ignore - from ._models import DeviceListResult # type: ignore - from ._models import DevicePropertiesFormat # type: ignore - from ._models import DeviceRegistrationKey # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ImageReference # type: ignore - from ._models import LinuxConfiguration # type: ignore - from ._models import NetworkFunction # type: ignore - from ._models import NetworkFunctionListResult # type: ignore - from ._models import NetworkFunctionRoleConfiguration # type: ignore - from ._models import NetworkFunctionRoleInstanceListResult # type: ignore - from ._models import NetworkFunctionSkuDetails # type: ignore - from ._models import NetworkFunctionSkuListResult # type: ignore - from ._models import NetworkFunctionSkuRoleDetails # type: ignore - from ._models import NetworkFunctionTemplate # type: ignore - from ._models import NetworkFunctionUserConfiguration # type: ignore - from ._models import NetworkFunctionUserConfigurationOsProfile # type: ignore - from ._models import NetworkFunctionVendor # type: ignore - from ._models import NetworkFunctionVendorConfiguration # type: ignore - from ._models import NetworkFunctionVendorListResult # type: ignore - from ._models import NetworkInterface # type: ignore - from ._models import NetworkInterfaceIPConfiguration # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import OsDisk # type: ignore - from ._models import OsProfile # type: ignore - from ._models import PreviewSubscription # type: ignore - from ._models import PreviewSubscriptionsList # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Resource # type: ignore - from ._models import RoleInstance # type: ignore - from ._models import SkuOverview # type: ignore - from ._models import SshConfiguration # type: ignore - from ._models import SshPublicKey # type: ignore - from ._models import StorageProfile # type: ignore - from ._models import SubResource # type: ignore - from ._models import SystemData # type: ignore - from ._models import TagsObject # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import Vendor # type: ignore - from ._models import VendorListResult # type: ignore - from ._models import VendorNetworkFunction # type: ignore - from ._models import VendorNetworkFunctionListResult # type: ignore - from ._models import VendorSku # type: ignore - from ._models import VendorSkuListResult # type: ignore - from ._models import VirtualHardDisk # type: ignore +from ._models_py3 import AzureStackEdgeFormat +from ._models_py3 import CustomProfile +from ._models_py3 import DataDisk +from ._models_py3 import Device +from ._models_py3 import DeviceListResult +from ._models_py3 import DevicePropertiesFormat +from ._models_py3 import DeviceRegistrationKey +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ExecuteRequestParameters +from ._models_py3 import ImageReference +from ._models_py3 import LinuxConfiguration +from ._models_py3 import NetworkFunction +from ._models_py3 import NetworkFunctionListResult +from ._models_py3 import NetworkFunctionRoleConfiguration +from ._models_py3 import NetworkFunctionRoleInstanceListResult +from ._models_py3 import NetworkFunctionSkuDetails +from ._models_py3 import NetworkFunctionSkuListResult +from ._models_py3 import NetworkFunctionSkuRoleDetails +from ._models_py3 import NetworkFunctionTemplate +from ._models_py3 import NetworkFunctionUserConfiguration +from ._models_py3 import NetworkFunctionUserConfigurationOsProfile +from ._models_py3 import NetworkFunctionVendor +from ._models_py3 import NetworkFunctionVendorConfiguration +from ._models_py3 import NetworkFunctionVendorListResult +from ._models_py3 import NetworkInterface +from ._models_py3 import NetworkInterfaceIPConfiguration +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OsDisk +from ._models_py3 import OsProfile +from ._models_py3 import PreviewSubscription +from ._models_py3 import PreviewSubscriptionsList +from ._models_py3 import ProxyResource +from ._models_py3 import RequestMetadata +from ._models_py3 import Resource +from ._models_py3 import RoleInstance +from ._models_py3 import SkuCredential +from ._models_py3 import SkuOverview +from ._models_py3 import SshConfiguration +from ._models_py3 import SshPublicKey +from ._models_py3 import StorageProfile +from ._models_py3 import SubResource +from ._models_py3 import SystemData +from ._models_py3 import TagsObject +from ._models_py3 import TrackedResource +from ._models_py3 import Vendor +from ._models_py3 import VendorListResult +from ._models_py3 import VendorNetworkFunction +from ._models_py3 import VendorNetworkFunctionListResult +from ._models_py3 import VendorSku +from ._models_py3 import VendorSkuListResult +from ._models_py3 import VirtualHardDisk + from ._hybrid_network_management_client_enums import ( + ActionType, CreatedByType, DeviceType, DiskCreateOptionTypes, + HttpMethod, IPAllocationMethod, IPVersion, NetworkFunctionRoleConfigurationType, NetworkFunctionType, OperatingSystemTypes, OperationalState, + Origin, ProvisioningState, SkuDeploymentMode, SkuType, @@ -129,8 +84,11 @@ VendorProvisioningState, VirtualMachineSizeTypes, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ + 'AzureStackEdgeFormat', 'CustomProfile', 'DataDisk', 'Device', @@ -140,6 +98,7 @@ 'ErrorAdditionalInfo', 'ErrorDetail', 'ErrorResponse', + 'ExecuteRequestParameters', 'ImageReference', 'LinuxConfiguration', 'NetworkFunction', @@ -159,14 +118,16 @@ 'NetworkInterfaceIPConfiguration', 'Operation', 'OperationDisplay', - 'OperationList', + 'OperationListResult', 'OsDisk', 'OsProfile', 'PreviewSubscription', 'PreviewSubscriptionsList', 'ProxyResource', + 'RequestMetadata', 'Resource', 'RoleInstance', + 'SkuCredential', 'SkuOverview', 'SshConfiguration', 'SshPublicKey', @@ -182,15 +143,18 @@ 'VendorSku', 'VendorSkuListResult', 'VirtualHardDisk', + 'ActionType', 'CreatedByType', 'DeviceType', 'DiskCreateOptionTypes', + 'HttpMethod', 'IPAllocationMethod', 'IPVersion', 'NetworkFunctionRoleConfigurationType', 'NetworkFunctionType', 'OperatingSystemTypes', 'OperationalState', + 'Origin', 'ProvisioningState', 'SkuDeploymentMode', 'SkuType', @@ -199,3 +163,5 @@ 'VendorProvisioningState', 'VirtualMachineSizeTypes', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_hybrid_network_management_client_enums.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_hybrid_network_management_client_enums.py index baad5c996ba4..8f4a6b934a96 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_hybrid_network_management_client_enums.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_hybrid_network_management_client_enums.py @@ -6,27 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -35,21 +25,32 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the device. """ UNKNOWN = "Unknown" AZURE_STACK_EDGE = "AzureStackEdge" -class DiskCreateOptionTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created. """ UNKNOWN = "Unknown" EMPTY = "Empty" -class IPAllocationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HttpMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The http method of the request. + """ + + UNKNOWN = "Unknown" + POST = "Post" + PUT = "Put" + GET = "Get" + PATCH = "Patch" + DELETE = "Delete" + +class IPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """IP address allocation method. """ @@ -57,21 +58,21 @@ class IPAllocationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STATIC = "Static" DYNAMIC = "Dynamic" -class IPVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """IP address version. """ UNKNOWN = "Unknown" I_PV4 = "IPv4" -class NetworkFunctionRoleConfigurationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkFunctionRoleConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Role type. """ UNKNOWN = "Unknown" VIRTUAL_MACHINE = "VirtualMachine" -class NetworkFunctionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkFunctionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The network function type. """ @@ -79,7 +80,7 @@ class NetworkFunctionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): VIRTUAL_NETWORK_FUNCTION = "VirtualNetworkFunction" CONTAINERIZED_NETWORK_FUNCTION = "ContainerizedNetworkFunction" -class OperatingSystemTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS type. """ @@ -87,7 +88,7 @@ class OperatingSystemTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): WINDOWS = "Windows" LINUX = "Linux" -class OperationalState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationalState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operational state of the role instance. """ @@ -97,7 +98,16 @@ class OperationalState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STOPPING = "Stopping" STARTING = "Starting" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -109,7 +119,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CANCELED = "Canceled" DELETED = "Deleted" -class SkuDeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuDeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku deployment mode. """ @@ -117,7 +127,7 @@ class SkuDeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AZURE = "Azure" PRIVATE_EDGE_ZONE = "PrivateEdgeZone" -class SkuType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sku type. """ @@ -126,7 +136,7 @@ class SkuType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SDWAN = "SDWAN" FIREWALL = "Firewall" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current device status. """ @@ -135,7 +145,7 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTERED = "Registered" DELETED = "Deleted" -class VendorProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VendorProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current vendor provisioning state. """ @@ -146,7 +156,7 @@ class VendorProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum DEPROVISIONED = "Deprovisioned" USER_DATA_VALIDATION_FAILED = "UserDataValidationFailed" -class VirtualMachineSizeTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The size of the virtual machine. """ @@ -178,7 +188,7 @@ class VirtualMachineSizeTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum STANDARD_F8_S = "Standard_F8s" STANDARD_F16_S = "Standard_F16s" -class VMSwitchType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VMSwitchType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the VM switch. """ diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models.py deleted file mode 100644 index 272ebc85d9ab..000000000000 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models.py +++ /dev/null @@ -1,1872 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class CustomProfile(msrest.serialization.Model): - """Specifies the custom settings for the virtual machine. - - :param metadata_configuration_path: Path for metadata configuration. - :type metadata_configuration_path: str - """ - - _attribute_map = { - 'metadata_configuration_path': {'key': 'metadataConfigurationPath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomProfile, self).__init__(**kwargs) - self.metadata_configuration_path = kwargs.get('metadata_configuration_path', None) - - -class DataDisk(msrest.serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. :code:`
`:code:`
` For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - - :param create_option: Specifies how the virtual machine should be created. Possible values - include: "Unknown", "Empty". - :type create_option: str or ~hybrid_network_management_client.models.DiskCreateOptionTypes - :param name: The name of data disk. - :type name: str - :param disk_size_gb: Specifies the size of an empty disk in gigabytes. This element can be used - to overwrite the size of the disk in a virtual machine image. - :type disk_size_gb: int - """ - - _attribute_map = { - 'create_option': {'key': 'createOption', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DataDisk, self).__init__(**kwargs) - self.create_option = kwargs.get('create_option', None) - self.name = kwargs.get('name', None) - self.disk_size_gb = kwargs.get('disk_size_gb', None) - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class Device(TrackedResource): - """Device resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar status: The current device status. Possible values include: "Unknown", "NotRegistered", - "Registered", "Deleted". - :vartype status: str or ~hybrid_network_management_client.models.Status - :ivar provisioning_state: The provisioning state of the device resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param device_type: The type of the device.Constant filled by server. Possible values include: - "Unknown", "AzureStackEdge". - :type device_type: str or ~hybrid_network_management_client.models.DeviceType - :param azure_stack_edge: The reference to the Azure stack edge device. Once set, it cannot be - updated. - :type azure_stack_edge: ~hybrid_network_management_client.models.SubResource - :ivar network_functions: The list of network functions deployed on the device. - :vartype network_functions: list[~hybrid_network_management_client.models.SubResource] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'network_functions': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'azure_stack_edge': {'key': 'properties.azureStackEdge', 'type': 'SubResource'}, - 'network_functions': {'key': 'properties.networkFunctions', 'type': '[SubResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(Device, self).__init__(**kwargs) - self.system_data = None - self.status = None - self.provisioning_state = None - self.device_type = None # type: Optional[str] - self.azure_stack_edge = kwargs.get('azure_stack_edge', None) - self.network_functions = None - - -class DeviceListResult(msrest.serialization.Model): - """Response for devices API service call. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: A list of devices. - :type value: list[~hybrid_network_management_client.models.Device] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Device]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DeviceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class DevicePropertiesFormat(msrest.serialization.Model): - """Device properties. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: . - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The current device status. Possible values include: "Unknown", "NotRegistered", - "Registered", "Deleted". - :vartype status: str or ~hybrid_network_management_client.models.Status - :ivar provisioning_state: The provisioning state of the device resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param device_type: Required. The type of the device.Constant filled by server. Possible - values include: "Unknown", "AzureStackEdge". - :type device_type: str or ~hybrid_network_management_client.models.DeviceType - :param azure_stack_edge: The reference to the Azure stack edge device. Once set, it cannot be - updated. - :type azure_stack_edge: ~hybrid_network_management_client.models.SubResource - :ivar network_functions: The list of network functions deployed on the device. - :vartype network_functions: list[~hybrid_network_management_client.models.SubResource] - """ - - _validation = { - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'device_type': {'required': True}, - 'network_functions': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'device_type': {'key': 'deviceType', 'type': 'str'}, - 'azure_stack_edge': {'key': 'azureStackEdge', 'type': 'SubResource'}, - 'network_functions': {'key': 'networkFunctions', 'type': '[SubResource]'}, - } - - _subtype_map = { - 'device_type': {} - } - - def __init__( - self, - **kwargs - ): - super(DevicePropertiesFormat, self).__init__(**kwargs) - self.status = None - self.provisioning_state = None - self.device_type = None # type: Optional[str] - self.azure_stack_edge = kwargs.get('azure_stack_edge', None) - self.network_functions = None - - -class DeviceRegistrationKey(msrest.serialization.Model): - """The device registration key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar registration_key: The registration key for the device. - :vartype registration_key: str - """ - - _validation = { - 'registration_key': {'readonly': True}, - } - - _attribute_map = { - 'registration_key': {'key': 'registrationKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DeviceRegistrationKey, self).__init__(**kwargs) - self.registration_key = None - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~hybrid_network_management_client.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~hybrid_network_management_client.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~hybrid_network_management_client.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ImageReference(msrest.serialization.Model): - """The image reference properties. - - :param publisher: The image publisher. - :type publisher: str - :param offer: Specifies the offer of the image used to create the virtual machine. - :type offer: str - :param sku: The image SKU. - :type sku: str - :param version: Specifies the version of the image used to create the virtual machine. The - allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. - Specify 'latest' to use the latest version of an image available at deploy time. Even if you - use 'latest', the VM image will not automatically update after deploy time even if a new - version becomes available. - :type version: str - :param exact_version: Specifies in decimal numbers, the exact version of image used to create - the virtual machine. - :type exact_version: str - """ - - _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'exact_version': {'key': 'exactVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageReference, self).__init__(**kwargs) - self.publisher = kwargs.get('publisher', None) - self.offer = kwargs.get('offer', None) - self.sku = kwargs.get('sku', None) - self.version = kwargs.get('version', None) - self.exact_version = kwargs.get('exact_version', None) - - -class LinuxConfiguration(msrest.serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. - - :param ssh: Specifies the ssh key configuration for a Linux OS. - :type ssh: ~hybrid_network_management_client.models.SshConfiguration - """ - - _attribute_map = { - 'ssh': {'key': 'ssh', 'type': 'SshConfiguration'}, - } - - def __init__( - self, - **kwargs - ): - super(LinuxConfiguration, self).__init__(**kwargs) - self.ssh = kwargs.get('ssh', None) - - -class NetworkFunction(TrackedResource): - """Network function resource response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: A unique read-only string that changes whenever the resource is updated. - :type etag: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the network function resource. Possible - values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", - "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param device: The reference to the device resource. Once set, it cannot be updated. - :type device: ~hybrid_network_management_client.models.SubResource - :param sku_name: The sku name for the network function. Once set, it cannot be updated. - :type sku_name: str - :ivar sku_type: The sku type for the network function. Possible values include: "Unknown", - "EvolvedPacketCore", "SDWAN", "Firewall". - :vartype sku_type: str or ~hybrid_network_management_client.models.SkuType - :param vendor_name: The vendor name for the network function. Once set, it cannot be updated. - :type vendor_name: str - :ivar service_key: The service key for the network function resource. - :vartype service_key: str - :ivar vendor_provisioning_state: The vendor provisioning state for the network function - resource. Possible values include: "Unknown", "NotProvisioned", "Provisioning", "Provisioned", - "Deprovisioned", "UserDataValidationFailed". - :vartype vendor_provisioning_state: str or - ~hybrid_network_management_client.models.VendorProvisioningState - :ivar managed_application: The resource URI of the managed application. - :vartype managed_application: ~hybrid_network_management_client.models.SubResource - :param managed_application_parameters: The parameters for the managed application. - :type managed_application_parameters: any - :param network_function_container_configurations: The network function container configurations - from the user. - :type network_function_container_configurations: any - :param network_function_user_configurations: The network function configurations from the user. - :type network_function_user_configurations: - list[~hybrid_network_management_client.models.NetworkFunctionUserConfiguration] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'sku_type': {'readonly': True}, - 'service_key': {'readonly': True}, - 'vendor_provisioning_state': {'readonly': True}, - 'managed_application': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'device': {'key': 'properties.device', 'type': 'SubResource'}, - 'sku_name': {'key': 'properties.skuName', 'type': 'str'}, - 'sku_type': {'key': 'properties.skuType', 'type': 'str'}, - 'vendor_name': {'key': 'properties.vendorName', 'type': 'str'}, - 'service_key': {'key': 'properties.serviceKey', 'type': 'str'}, - 'vendor_provisioning_state': {'key': 'properties.vendorProvisioningState', 'type': 'str'}, - 'managed_application': {'key': 'properties.managedApplication', 'type': 'SubResource'}, - 'managed_application_parameters': {'key': 'properties.managedApplicationParameters', 'type': 'object'}, - 'network_function_container_configurations': {'key': 'properties.networkFunctionContainerConfigurations', 'type': 'object'}, - 'network_function_user_configurations': {'key': 'properties.networkFunctionUserConfigurations', 'type': '[NetworkFunctionUserConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunction, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.system_data = None - self.provisioning_state = None - self.device = kwargs.get('device', None) - self.sku_name = kwargs.get('sku_name', None) - self.sku_type = None - self.vendor_name = kwargs.get('vendor_name', None) - self.service_key = None - self.vendor_provisioning_state = None - self.managed_application = None - self.managed_application_parameters = kwargs.get('managed_application_parameters', None) - self.network_function_container_configurations = kwargs.get('network_function_container_configurations', None) - self.network_function_user_configurations = kwargs.get('network_function_user_configurations', None) - - -class NetworkFunctionListResult(msrest.serialization.Model): - """Response for network function API service call. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: A list of network function resources in a subscription or resource group. - :type value: list[~hybrid_network_management_client.models.NetworkFunction] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkFunction]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class NetworkFunctionRoleConfiguration(msrest.serialization.Model): - """Network function role configuration. - - :param role_name: The name of the network function role. - :type role_name: str - :param role_type: Role type. Possible values include: "Unknown", "VirtualMachine". - :type role_type: str or - ~hybrid_network_management_client.models.NetworkFunctionRoleConfigurationType - :param virtual_machine_size: The size of the virtual machine. Possible values include: - "Unknown", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", - "Standard_DS12_v2", "Standard_DS13_v2", "Standard_F1", "Standard_F2", "Standard_F4", - "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s". - :type virtual_machine_size: str or - ~hybrid_network_management_client.models.VirtualMachineSizeTypes - :param os_profile: Specifies the operating system settings for the role instance. This value - can be updated during the deployment of network function. - :type os_profile: ~hybrid_network_management_client.models.OsProfile - :param user_data_template: The user data template for customers. This is a json schema template - describing the format and data type of user data parameters. - :type user_data_template: any - :param user_data_parameters: The user parameters for customers. The format of user data - parameters has to be matched with the provided user data template. - :type user_data_parameters: any - :param network_interfaces: The network interface configurations. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] - :param storage_profile: Specifies the storage settings for the virtual machine disks. - :type storage_profile: ~hybrid_network_management_client.models.StorageProfile - :param custom_profile: Specifies the custom settings for the virtual machine. - :type custom_profile: ~hybrid_network_management_client.models.CustomProfile - """ - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - 'virtual_machine_size': {'key': 'virtualMachineSize', 'type': 'str'}, - 'os_profile': {'key': 'osProfile', 'type': 'OsProfile'}, - 'user_data_template': {'key': 'userDataTemplate', 'type': 'object'}, - 'user_data_parameters': {'key': 'userDataParameters', 'type': 'object'}, - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, - 'storage_profile': {'key': 'storageProfile', 'type': 'StorageProfile'}, - 'custom_profile': {'key': 'customProfile', 'type': 'CustomProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionRoleConfiguration, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - self.role_type = kwargs.get('role_type', None) - self.virtual_machine_size = kwargs.get('virtual_machine_size', None) - self.os_profile = kwargs.get('os_profile', None) - self.user_data_template = kwargs.get('user_data_template', None) - self.user_data_parameters = kwargs.get('user_data_parameters', None) - self.network_interfaces = kwargs.get('network_interfaces', None) - self.storage_profile = kwargs.get('storage_profile', None) - self.custom_profile = kwargs.get('custom_profile', None) - - -class NetworkFunctionRoleInstanceListResult(msrest.serialization.Model): - """List of role instances of vendor network function. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: A list of role instances. - :vartype value: list[~hybrid_network_management_client.models.RoleInstance] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionRoleInstanceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class NetworkFunctionSkuDetails(msrest.serialization.Model): - """The network function sku details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param sku_type: The network function sku type. Possible values include: "Unknown", - "EvolvedPacketCore", "SDWAN", "Firewall". - :type sku_type: str or ~hybrid_network_management_client.models.SkuType - :param value: The network function sku role details. - :type value: list[~hybrid_network_management_client.models.NetworkFunctionSkuRoleDetails] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'sku_type': {'key': 'skuType', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[NetworkFunctionSkuRoleDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionSkuDetails, self).__init__(**kwargs) - self.sku_type = kwargs.get('sku_type', None) - self.value = kwargs.get('value', None) - self.next_link = None - - -class NetworkFunctionSkuListResult(msrest.serialization.Model): - """A list of available network function skus. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The network function vendor sku overview properties. - :type value: list[~hybrid_network_management_client.models.SkuOverview] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuOverview]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionSkuListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class NetworkFunctionSkuRoleDetails(msrest.serialization.Model): - """The network function user configuration. - - :param role_name: The name of the network function role. - :type role_name: str - :param user_data_template: The user data template for customers. - :type user_data_template: any - :param user_data_parameters: The user parameters for customers. - :type user_data_parameters: any - :param network_interfaces: The network interface configuration. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] - """ - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - 'user_data_template': {'key': 'userDataTemplate', 'type': 'object'}, - 'user_data_parameters': {'key': 'userDataParameters', 'type': 'object'}, - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionSkuRoleDetails, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - self.user_data_template = kwargs.get('user_data_template', None) - self.user_data_parameters = kwargs.get('user_data_parameters', None) - self.network_interfaces = kwargs.get('network_interfaces', None) - - -class NetworkFunctionTemplate(msrest.serialization.Model): - """The network function template. - - :param network_function_role_configurations: An array of network function role definitions. - :type network_function_role_configurations: - list[~hybrid_network_management_client.models.NetworkFunctionRoleConfiguration] - """ - - _attribute_map = { - 'network_function_role_configurations': {'key': 'networkFunctionRoleConfigurations', 'type': '[NetworkFunctionRoleConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionTemplate, self).__init__(**kwargs) - self.network_function_role_configurations = kwargs.get('network_function_role_configurations', None) - - -class NetworkFunctionUserConfiguration(msrest.serialization.Model): - """The network function user configuration. - - :param role_name: The name of the network function role. - :type role_name: str - :param user_data_parameters: The user data parameters from the customer. - :type user_data_parameters: any - :param network_interfaces: The network interface configuration. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] - :param os_profile: Specifies the operating system settings for the role instance. - :type os_profile: - ~hybrid_network_management_client.models.NetworkFunctionUserConfigurationOsProfile - """ - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - 'user_data_parameters': {'key': 'userDataParameters', 'type': 'object'}, - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, - 'os_profile': {'key': 'osProfile', 'type': 'NetworkFunctionUserConfigurationOsProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionUserConfiguration, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - self.user_data_parameters = kwargs.get('user_data_parameters', None) - self.network_interfaces = kwargs.get('network_interfaces', None) - self.os_profile = kwargs.get('os_profile', None) - - -class NetworkFunctionUserConfigurationOsProfile(msrest.serialization.Model): - """Specifies the operating system settings for the role instance. - - :param custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the virtual machine. The maximum - length of the binary array is 65535 bytes. :code:`
`:code:`
` **Note: Do not pass any - secrets or passwords in customData property** :code:`
`:code:`
` This property cannot be - updated after the VM is created. :code:`
`:code:`
` customData is passed to the VM to be - saved as a file. For more information see `Custom Data on Azure VMs - `_ - :code:`
`:code:`
` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :type custom_data: str - """ - - _attribute_map = { - 'custom_data': {'key': 'customData', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionUserConfigurationOsProfile, self).__init__(**kwargs) - self.custom_data = kwargs.get('custom_data', None) - - -class NetworkFunctionVendor(msrest.serialization.Model): - """The network function vendor. - - :param vendor_name: The network function vendor name. - :type vendor_name: str - :param sku_list: The network function sku list. - :type sku_list: list[~hybrid_network_management_client.models.SkuOverview] - """ - - _attribute_map = { - 'vendor_name': {'key': 'properties.vendorName', 'type': 'str'}, - 'sku_list': {'key': 'properties.skuList', 'type': '[SkuOverview]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionVendor, self).__init__(**kwargs) - self.vendor_name = kwargs.get('vendor_name', None) - self.sku_list = kwargs.get('sku_list', None) - - -class NetworkFunctionVendorConfiguration(msrest.serialization.Model): - """Network function vendor configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param role_name: The name of the vendor network function role. - :type role_name: str - :param os_profile: Specifies the operating system settings for the role instance. - :type os_profile: ~hybrid_network_management_client.models.OsProfile - :ivar user_data_parameters: The user parameters from the customer. - :vartype user_data_parameters: any - :param network_interfaces: The network interface configurations. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] - """ - - _validation = { - 'user_data_parameters': {'readonly': True}, - } - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - 'os_profile': {'key': 'osProfile', 'type': 'OsProfile'}, - 'user_data_parameters': {'key': 'userDataParameters', 'type': 'object'}, - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionVendorConfiguration, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - self.os_profile = kwargs.get('os_profile', None) - self.user_data_parameters = None - self.network_interfaces = kwargs.get('network_interfaces', None) - - -class NetworkFunctionVendorListResult(msrest.serialization.Model): - """The network function vendor list result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: A list of available network function vendors and skus. - :type value: list[~hybrid_network_management_client.models.NetworkFunctionVendor] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkFunctionVendor]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkFunctionVendorListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class NetworkInterface(msrest.serialization.Model): - """Network interface properties. - - :param network_interface_name: The name of the network interface. - :type network_interface_name: str - :param mac_address: The MAC address of the network interface. - :type mac_address: str - :param ip_configurations: A list of IP configurations of the network interface. - :type ip_configurations: - list[~hybrid_network_management_client.models.NetworkInterfaceIPConfiguration] - :param vm_switch_type: The type of the VM switch. Possible values include: "Unknown", - "Management", "Wan", "Lan". - :type vm_switch_type: str or ~hybrid_network_management_client.models.VMSwitchType - """ - - _attribute_map = { - 'network_interface_name': {'key': 'networkInterfaceName', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'ip_configurations': {'key': 'ipConfigurations', 'type': '[NetworkInterfaceIPConfiguration]'}, - 'vm_switch_type': {'key': 'vmSwitchType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkInterface, self).__init__(**kwargs) - self.network_interface_name = kwargs.get('network_interface_name', None) - self.mac_address = kwargs.get('mac_address', None) - self.ip_configurations = kwargs.get('ip_configurations', None) - self.vm_switch_type = kwargs.get('vm_switch_type', None) - - -class NetworkInterfaceIPConfiguration(msrest.serialization.Model): - """Network interface IP configuration properties. - - :param ip_allocation_method: IP address allocation method. Possible values include: "Unknown", - "Static", "Dynamic". - :type ip_allocation_method: str or ~hybrid_network_management_client.models.IPAllocationMethod - :param ip_address: The value of the IP address. - :type ip_address: str - :param subnet: The value of the subnet. - :type subnet: str - :param gateway: The value of the gateway. - :type gateway: str - :param ip_version: IP address version. Possible values include: "Unknown", "IPv4". - :type ip_version: str or ~hybrid_network_management_client.models.IPVersion - :param dns_servers: The list of DNS servers IP addresses. - :type dns_servers: list[str] - """ - - _attribute_map = { - 'ip_allocation_method': {'key': 'ipAllocationMethod', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - 'ip_version': {'key': 'ipVersion', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkInterfaceIPConfiguration, self).__init__(**kwargs) - self.ip_allocation_method = kwargs.get('ip_allocation_method', None) - self.ip_address = kwargs.get('ip_address', None) - self.subnet = kwargs.get('subnet', None) - self.gateway = kwargs.get('gateway', None) - self.ip_version = kwargs.get('ip_version', None) - self.dns_servers = kwargs.get('dns_servers', None) - - -class Operation(msrest.serialization.Model): - """Object that describes a single Microsoft.HybridNetwork operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: The object that represents the operation. - :vartype display: ~hybrid_network_management_client.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = None - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.HybridNetwork. - :type provider: str - :param resource: Resource on which the operation is performed: Registration definition, - registration assignment, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationList(msrest.serialization.Model): - """A list of the operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: A list of Microsoft.HybridNetwork operations. - :vartype value: list[~hybrid_network_management_client.models.Operation] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OsDisk(msrest.serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. :code:`
`:code:`
` For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - - :param os_type: The OS type. Possible values include: "Unknown", "Windows", "Linux". - :type os_type: str or ~hybrid_network_management_client.models.OperatingSystemTypes - :param name: The VHD name. - :type name: str - :param vhd: The virtual hard disk. - :type vhd: ~hybrid_network_management_client.models.VirtualHardDisk - :param disk_size_gb: Specifies the size of os disk in gigabytes. This is the fully expanded - disk size needed of the VHD image on the ASE. This disk size should be greater than the size of - the VHD provided in vhdUri. - :type disk_size_gb: int - """ - - _attribute_map = { - 'os_type': {'key': 'osType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'vhd': {'key': 'vhd', 'type': 'VirtualHardDisk'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(OsDisk, self).__init__(**kwargs) - self.os_type = kwargs.get('os_type', None) - self.name = kwargs.get('name', None) - self.vhd = kwargs.get('vhd', None) - self.disk_size_gb = kwargs.get('disk_size_gb', None) - - -class OsProfile(msrest.serialization.Model): - """Specifies the operating system settings for the role instance. - - :param admin_username: Specifies the name of the administrator account. - :code:`
`:code:`
` **Windows-only restriction:** Cannot end in "." - :code:`
`:code:`
` **Disallowed values:** "administrator", "admin", "user", "user1", - "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", - "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", - "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". - :code:`
`:code:`
` **Minimum-length (Linux):** 1 character :code:`
`:code:`
` - **Max-length (Linux):** 64 characters :code:`
`:code:`
` **Max-length (Windows):** 20 - characters :code:`
`:code:`
`:code:`
  • ` For root access to the Linux VM, see `Using - root privileges on Linux virtual machines in Azure - `_\ - :code:`
    `:code:`
  • ` For a list of built-in system users on Linux that should not be used - in this field, see `Selecting User Names for Linux on Azure - `_. - :type admin_username: str - :param linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `:code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `:code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :type linux_configuration: ~hybrid_network_management_client.models.LinuxConfiguration - :param custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the virtual machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `:code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `:code:`
    ` This property cannot be - updated after the VM is created. :code:`
    `:code:`
    ` customData is passed to the VM to be - saved as a file. For more information see `Custom Data on Azure VMs - `_ - :code:`
    `:code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :type custom_data: str - :param custom_data_required: Indicates if custom data is required to deploy this role. - :type custom_data_required: bool - """ - - _attribute_map = { - 'admin_username': {'key': 'adminUsername', 'type': 'str'}, - 'linux_configuration': {'key': 'linuxConfiguration', 'type': 'LinuxConfiguration'}, - 'custom_data': {'key': 'customData', 'type': 'str'}, - 'custom_data_required': {'key': 'customDataRequired', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(OsProfile, self).__init__(**kwargs) - self.admin_username = kwargs.get('admin_username', None) - self.linux_configuration = kwargs.get('linux_configuration', None) - self.custom_data = kwargs.get('custom_data', None) - self.custom_data_required = kwargs.get('custom_data_required', True) - - -class PreviewSubscription(msrest.serialization.Model): - """Customer subscription which can use a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The preview subscription ID. - :vartype name: str - :ivar id: The ARM ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the PreviewSubscription resource. Possible - values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", - "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PreviewSubscription, self).__init__(**kwargs) - self.name = None - self.id = None - self.type = None - self.system_data = None - self.provisioning_state = None - - -class PreviewSubscriptionsList(msrest.serialization.Model): - """A list of customer subscriptions which can use a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: A list of preview subscriptions. - :type value: list[~hybrid_network_management_client.models.PreviewSubscription] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PreviewSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PreviewSubscriptionsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class RoleInstance(msrest.serialization.Model): - """The role instance sub resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: The role instance name. - :type name: str - :param id: The ARM ID of the resource. - :type id: str - :param type: The type of the resource. - :type type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the RoleInstance resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param operational_state: The operational state of the role instance. Possible values include: - "Unknown", "Stopped", "Running", "Stopping", "Starting". - :type operational_state: str or ~hybrid_network_management_client.models.OperationalState - """ - - _validation = { - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'operational_state': {'key': 'properties.operationalState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleInstance, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.system_data = None - self.provisioning_state = None - self.operational_state = kwargs.get('operational_state', None) - - -class SkuOverview(msrest.serialization.Model): - """The network function sku overview. - - :param sku_name: The vendor sku name. - :type sku_name: str - :param sku_type: The vendor sku type. Possible values include: "Unknown", "EvolvedPacketCore", - "SDWAN", "Firewall". - :type sku_type: str or ~hybrid_network_management_client.models.SkuType - """ - - _attribute_map = { - 'sku_name': {'key': 'skuName', 'type': 'str'}, - 'sku_type': {'key': 'skuType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuOverview, self).__init__(**kwargs) - self.sku_name = kwargs.get('sku_name', None) - self.sku_type = kwargs.get('sku_type', None) - - -class SshConfiguration(msrest.serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :param public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :type public_keys: list[~hybrid_network_management_client.models.SshPublicKey] - """ - - _attribute_map = { - 'public_keys': {'key': 'publicKeys', 'type': '[SshPublicKey]'}, - } - - def __init__( - self, - **kwargs - ): - super(SshConfiguration, self).__init__(**kwargs) - self.public_keys = kwargs.get('public_keys', None) - - -class SshPublicKey(msrest.serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the public key is placed. - - :param path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :type path: str - :param key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `:code:`
    ` For creating - ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :type key_data: str - """ - - _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'key_data': {'key': 'keyData', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SshPublicKey, self).__init__(**kwargs) - self.path = kwargs.get('path', None) - self.key_data = kwargs.get('key_data', None) - - -class StorageProfile(msrest.serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :param image_reference: The image reference properties. - :type image_reference: ~hybrid_network_management_client.models.ImageReference - :param os_disk: Specifies information about the operating system disk used by the virtual - machine. - :type os_disk: ~hybrid_network_management_client.models.OsDisk - :param data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. - :type data_disks: list[~hybrid_network_management_client.models.DataDisk] - """ - - _attribute_map = { - 'image_reference': {'key': 'imageReference', 'type': 'ImageReference'}, - 'os_disk': {'key': 'osDisk', 'type': 'OsDisk'}, - 'data_disks': {'key': 'dataDisks', 'type': '[DataDisk]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageProfile, self).__init__(**kwargs) - self.image_reference = kwargs.get('image_reference', None) - self.os_disk = kwargs.get('os_disk', None) - self.data_disks = kwargs.get('data_disks', None) - - -class SubResource(msrest.serialization.Model): - """Reference to another sub resource. - - :param id: Resource ID. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubResource, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~hybrid_network_management_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~hybrid_network_management_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TagsObject(msrest.serialization.Model): - """Tags object for patch operations. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsObject, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class Vendor(ProxyResource): - """Vendor resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the vendor resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :ivar skus: A list of IDs of the vendor skus offered by the vendor. - :vartype skus: list[~hybrid_network_management_client.models.SubResource] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'skus': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'skus': {'key': 'properties.skus', 'type': '[SubResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(Vendor, self).__init__(**kwargs) - self.system_data = None - self.provisioning_state = None - self.skus = None - - -class VendorListResult(msrest.serialization.Model): - """Response for vendors API service call. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: A list of vendors. - :type value: list[~hybrid_network_management_client.models.Vendor] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Vendor]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VendorListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class VendorNetworkFunction(ProxyResource): - """Vendor network function sub resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the vendor network function sub resource. - Possible values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", - "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param vendor_provisioning_state: The vendor controlled provisioning state of the vendor - network function. Possible values include: "Unknown", "NotProvisioned", "Provisioning", - "Provisioned", "Deprovisioned", "UserDataValidationFailed". - :type vendor_provisioning_state: str or - ~hybrid_network_management_client.models.VendorProvisioningState - :ivar sku_name: The name of the sku. Once set, it cannot be updated. - :vartype sku_name: str - :ivar sku_type: The sku type. Possible values include: "Unknown", "EvolvedPacketCore", "SDWAN", - "Firewall". - :vartype sku_type: str or ~hybrid_network_management_client.models.SkuType - :param network_function_vendor_configurations: An array of network function vendor - configurations. - :type network_function_vendor_configurations: - list[~hybrid_network_management_client.models.NetworkFunctionVendorConfiguration] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'sku_name': {'readonly': True}, - 'sku_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'vendor_provisioning_state': {'key': 'properties.vendorProvisioningState', 'type': 'str'}, - 'sku_name': {'key': 'properties.skuName', 'type': 'str'}, - 'sku_type': {'key': 'properties.skuType', 'type': 'str'}, - 'network_function_vendor_configurations': {'key': 'properties.networkFunctionVendorConfigurations', 'type': '[NetworkFunctionVendorConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(VendorNetworkFunction, self).__init__(**kwargs) - self.system_data = None - self.provisioning_state = None - self.vendor_provisioning_state = kwargs.get('vendor_provisioning_state', None) - self.sku_name = None - self.sku_type = None - self.network_function_vendor_configurations = kwargs.get('network_function_vendor_configurations', None) - - -class VendorNetworkFunctionListResult(msrest.serialization.Model): - """Response for vendors API service call. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: A list of vendor network functions. - :type value: list[~hybrid_network_management_client.models.VendorNetworkFunction] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[VendorNetworkFunction]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VendorNetworkFunctionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class VendorSku(ProxyResource): - """Sku sub resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the vendor sku sub resource. Possible - values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", - "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param sku_type: The sku type. Possible values include: "Unknown", "EvolvedPacketCore", - "SDWAN", "Firewall". - :type sku_type: str or ~hybrid_network_management_client.models.SkuType - :param deployment_mode: The sku deployment mode. Possible values include: "Unknown", "Azure", - "PrivateEdgeZone". - :type deployment_mode: str or ~hybrid_network_management_client.models.SkuDeploymentMode - :param network_function_type: The network function type. Possible values include: "Unknown", - "VirtualNetworkFunction", "ContainerizedNetworkFunction". - :type network_function_type: str or - ~hybrid_network_management_client.models.NetworkFunctionType - :param preview: Indicates if the vendor sku is in preview mode. - :type preview: bool - :param managed_application_parameters: The parameters for the managed application to be - supplied by the vendor. - :type managed_application_parameters: any - :param managed_application_template: The template for the managed application deployment. - :type managed_application_template: any - :param network_function_template: The template definition of the network function. - :type network_function_template: - ~hybrid_network_management_client.models.NetworkFunctionTemplate - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sku_type': {'key': 'properties.skuType', 'type': 'str'}, - 'deployment_mode': {'key': 'properties.deploymentMode', 'type': 'str'}, - 'network_function_type': {'key': 'properties.networkFunctionType', 'type': 'str'}, - 'preview': {'key': 'properties.preview', 'type': 'bool'}, - 'managed_application_parameters': {'key': 'properties.managedApplicationParameters', 'type': 'object'}, - 'managed_application_template': {'key': 'properties.managedApplicationTemplate', 'type': 'object'}, - 'network_function_template': {'key': 'properties.networkFunctionTemplate', 'type': 'NetworkFunctionTemplate'}, - } - - def __init__( - self, - **kwargs - ): - super(VendorSku, self).__init__(**kwargs) - self.system_data = None - self.provisioning_state = None - self.sku_type = kwargs.get('sku_type', None) - self.deployment_mode = kwargs.get('deployment_mode', None) - self.network_function_type = kwargs.get('network_function_type', None) - self.preview = kwargs.get('preview', None) - self.managed_application_parameters = kwargs.get('managed_application_parameters', None) - self.managed_application_template = kwargs.get('managed_application_template', None) - self.network_function_template = kwargs.get('network_function_template', None) - - -class VendorSkuListResult(msrest.serialization.Model): - """Response for list vendor sku API service call. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: A list of vendor skus offered by the vendor. - :type value: list[~hybrid_network_management_client.models.VendorSku] - :ivar next_link: The URI to get the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[VendorSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VendorSkuListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class VirtualHardDisk(msrest.serialization.Model): - """Describes the uri of a disk. - - :param uri: Specifies the virtual hard disk's uri. - :type uri: str - """ - - _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualHardDisk, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models_py3.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models_py3.py index 41919b0d527e..eed51b499cb8 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models_py3.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_models_py3.py @@ -7,19 +7,128 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._hybrid_network_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class DevicePropertiesFormat(msrest.serialization.Model): + """Device properties. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: AzureStackEdgeFormat. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar status: The current device status. Known values are: "Unknown", "NotRegistered", + "Registered", "Deleted". + :vartype status: str or ~azure.mgmt.hybridnetwork.models.Status + :ivar provisioning_state: The provisioning state of the device resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState + :ivar device_type: Required. The type of the device.Constant filled by server. Known values + are: "Unknown", "AzureStackEdge". + :vartype device_type: str or ~azure.mgmt.hybridnetwork.models.DeviceType + :ivar network_functions: The list of network functions deployed on the device. + :vartype network_functions: list[~azure.mgmt.hybridnetwork.models.SubResource] + """ + + _validation = { + 'status': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'device_type': {'required': True}, + 'network_functions': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'device_type': {'key': 'deviceType', 'type': 'str'}, + 'network_functions': {'key': 'networkFunctions', 'type': '[SubResource]'}, + } + + _subtype_map = { + 'device_type': {'AzureStackEdge': 'AzureStackEdgeFormat'} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(DevicePropertiesFormat, self).__init__(**kwargs) + self.status = None + self.provisioning_state = None + self.device_type = None # type: Optional[str] + self.network_functions = None + + +class AzureStackEdgeFormat(DevicePropertiesFormat): + """The reference to the Azure stack edge device. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar status: The current device status. Known values are: "Unknown", "NotRegistered", + "Registered", "Deleted". + :vartype status: str or ~azure.mgmt.hybridnetwork.models.Status + :ivar provisioning_state: The provisioning state of the device resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState + :ivar device_type: Required. The type of the device.Constant filled by server. Known values + are: "Unknown", "AzureStackEdge". + :vartype device_type: str or ~azure.mgmt.hybridnetwork.models.DeviceType + :ivar network_functions: The list of network functions deployed on the device. + :vartype network_functions: list[~azure.mgmt.hybridnetwork.models.SubResource] + :ivar azure_stack_edge: Required. The reference to the Azure stack edge device. + :vartype azure_stack_edge: ~azure.mgmt.hybridnetwork.models.SubResource + """ + + _validation = { + 'status': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'device_type': {'required': True}, + 'network_functions': {'readonly': True}, + 'azure_stack_edge': {'required': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'device_type': {'key': 'deviceType', 'type': 'str'}, + 'network_functions': {'key': 'networkFunctions', 'type': '[SubResource]'}, + 'azure_stack_edge': {'key': 'azureStackEdge', 'type': 'SubResource'}, + } + + def __init__( + self, + *, + azure_stack_edge: "_models.SubResource", + **kwargs + ): + """ + :keyword azure_stack_edge: Required. The reference to the Azure stack edge device. + :paramtype azure_stack_edge: ~azure.mgmt.hybridnetwork.models.SubResource + """ + super(AzureStackEdgeFormat, self).__init__(**kwargs) + self.device_type = 'AzureStackEdge' # type: str + self.azure_stack_edge = azure_stack_edge class CustomProfile(msrest.serialization.Model): """Specifies the custom settings for the virtual machine. - :param metadata_configuration_path: Path for metadata configuration. - :type metadata_configuration_path: str + :ivar metadata_configuration_path: Path for metadata configuration. + :vartype metadata_configuration_path: str """ _attribute_map = { @@ -32,6 +141,10 @@ def __init__( metadata_configuration_path: Optional[str] = None, **kwargs ): + """ + :keyword metadata_configuration_path: Path for metadata configuration. + :paramtype metadata_configuration_path: str + """ super(CustomProfile, self).__init__(**kwargs) self.metadata_configuration_path = metadata_configuration_path @@ -39,14 +152,14 @@ def __init__( class DataDisk(msrest.serialization.Model): """Specifies information about the operating system disk used by the virtual machine. :code:`
    `:code:`
    ` For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :param create_option: Specifies how the virtual machine should be created. Possible values - include: "Unknown", "Empty". - :type create_option: str or ~hybrid_network_management_client.models.DiskCreateOptionTypes - :param name: The name of data disk. - :type name: str - :param disk_size_gb: Specifies the size of an empty disk in gigabytes. This element can be used + :ivar create_option: Specifies how the virtual machine should be created. Known values are: + "Unknown", "Empty". + :vartype create_option: str or ~azure.mgmt.hybridnetwork.models.DiskCreateOptionTypes + :ivar name: The name of data disk. + :vartype name: str + :ivar disk_size_gb: Specifies the size of an empty disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. - :type disk_size_gb: int + :vartype disk_size_gb: int """ _attribute_map = { @@ -58,11 +171,21 @@ class DataDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Optional[Union[str, "DiskCreateOptionTypes"]] = None, + create_option: Optional[Union[str, "_models.DiskCreateOptionTypes"]] = None, name: Optional[str] = None, disk_size_gb: Optional[int] = None, **kwargs ): + """ + :keyword create_option: Specifies how the virtual machine should be created. Known values are: + "Unknown", "Empty". + :paramtype create_option: str or ~azure.mgmt.hybridnetwork.models.DiskCreateOptionTypes + :keyword name: The name of data disk. + :paramtype name: str + :keyword disk_size_gb: Specifies the size of an empty disk in gigabytes. This element can be + used to overwrite the size of the disk in a virtual machine image. + :paramtype disk_size_gb: int + """ super(DataDisk, self).__init__(**kwargs) self.create_option = create_option self.name = name @@ -100,6 +223,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -121,10 +246,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -149,6 +274,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -169,26 +300,23 @@ class Device(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar status: The current device status. Possible values include: "Unknown", "NotRegistered", + :vartype system_data: ~azure.mgmt.hybridnetwork.models.SystemData + :ivar status: The current device status. Known values are: "Unknown", "NotRegistered", "Registered", "Deleted". - :vartype status: str or ~hybrid_network_management_client.models.Status - :ivar provisioning_state: The provisioning state of the device resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param device_type: The type of the device.Constant filled by server. Possible values include: + :vartype status: str or ~azure.mgmt.hybridnetwork.models.Status + :ivar provisioning_state: The provisioning state of the device resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState + :ivar device_type: The type of the device.Constant filled by server. Known values are: "Unknown", "AzureStackEdge". - :type device_type: str or ~hybrid_network_management_client.models.DeviceType - :param azure_stack_edge: The reference to the Azure stack edge device. Once set, it cannot be - updated. - :type azure_stack_edge: ~hybrid_network_management_client.models.SubResource + :vartype device_type: str or ~azure.mgmt.hybridnetwork.models.DeviceType :ivar network_functions: The list of network functions deployed on the device. - :vartype network_functions: list[~hybrid_network_management_client.models.SubResource] + :vartype network_functions: list[~azure.mgmt.hybridnetwork.models.SubResource] """ _validation = { @@ -212,7 +340,6 @@ class Device(TrackedResource): 'status': {'key': 'properties.status', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'azure_stack_edge': {'key': 'properties.azureStackEdge', 'type': 'SubResource'}, 'network_functions': {'key': 'properties.networkFunctions', 'type': '[SubResource]'}, } @@ -221,15 +348,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - azure_stack_edge: Optional["SubResource"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(Device, self).__init__(tags=tags, location=location, **kwargs) self.system_data = None self.status = None self.provisioning_state = None self.device_type = None # type: Optional[str] - self.azure_stack_edge = azure_stack_edge self.network_functions = None @@ -238,8 +369,8 @@ class DeviceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: A list of devices. - :type value: list[~hybrid_network_management_client.models.Device] + :ivar value: A list of devices. + :vartype value: list[~azure.mgmt.hybridnetwork.models.Device] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -256,73 +387,18 @@ class DeviceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Device"]] = None, + value: Optional[List["_models.Device"]] = None, **kwargs ): + """ + :keyword value: A list of devices. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.Device] + """ super(DeviceListResult, self).__init__(**kwargs) self.value = value self.next_link = None -class DevicePropertiesFormat(msrest.serialization.Model): - """Device properties. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: . - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The current device status. Possible values include: "Unknown", "NotRegistered", - "Registered", "Deleted". - :vartype status: str or ~hybrid_network_management_client.models.Status - :ivar provisioning_state: The provisioning state of the device resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param device_type: Required. The type of the device.Constant filled by server. Possible - values include: "Unknown", "AzureStackEdge". - :type device_type: str or ~hybrid_network_management_client.models.DeviceType - :param azure_stack_edge: The reference to the Azure stack edge device. Once set, it cannot be - updated. - :type azure_stack_edge: ~hybrid_network_management_client.models.SubResource - :ivar network_functions: The list of network functions deployed on the device. - :vartype network_functions: list[~hybrid_network_management_client.models.SubResource] - """ - - _validation = { - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'device_type': {'required': True}, - 'network_functions': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'device_type': {'key': 'deviceType', 'type': 'str'}, - 'azure_stack_edge': {'key': 'azureStackEdge', 'type': 'SubResource'}, - 'network_functions': {'key': 'networkFunctions', 'type': '[SubResource]'}, - } - - _subtype_map = { - 'device_type': {} - } - - def __init__( - self, - *, - azure_stack_edge: Optional["SubResource"] = None, - **kwargs - ): - super(DevicePropertiesFormat, self).__init__(**kwargs) - self.status = None - self.provisioning_state = None - self.device_type = None # type: Optional[str] - self.azure_stack_edge = azure_stack_edge - self.network_functions = None - - class DeviceRegistrationKey(msrest.serialization.Model): """The device registration key. @@ -344,6 +420,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeviceRegistrationKey, self).__init__(**kwargs) self.registration_key = None @@ -373,6 +451,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -390,9 +470,9 @@ class ErrorDetail(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~hybrid_network_management_client.models.ErrorDetail] + :vartype details: list[~azure.mgmt.hybridnetwork.models.ErrorDetail] :ivar additional_info: The error additional info. - :vartype additional_info: list[~hybrid_network_management_client.models.ErrorAdditionalInfo] + :vartype additional_info: list[~azure.mgmt.hybridnetwork.models.ErrorAdditionalInfo] """ _validation = { @@ -415,6 +495,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -426,8 +508,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~hybrid_network_management_client.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.hybridnetwork.models.ErrorDetail """ _attribute_map = { @@ -437,31 +519,74 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.hybridnetwork.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error +class ExecuteRequestParameters(msrest.serialization.Model): + """Payload for execute request post call. + + All required parameters must be populated in order to send to Azure. + + :ivar service_endpoint: Required. The endpoint of service to call. + :vartype service_endpoint: str + :ivar request_metadata: Required. The request metadata. + :vartype request_metadata: ~azure.mgmt.hybridnetwork.models.RequestMetadata + """ + + _validation = { + 'service_endpoint': {'required': True}, + 'request_metadata': {'required': True}, + } + + _attribute_map = { + 'service_endpoint': {'key': 'serviceEndpoint', 'type': 'str'}, + 'request_metadata': {'key': 'requestMetadata', 'type': 'RequestMetadata'}, + } + + def __init__( + self, + *, + service_endpoint: str, + request_metadata: "_models.RequestMetadata", + **kwargs + ): + """ + :keyword service_endpoint: Required. The endpoint of service to call. + :paramtype service_endpoint: str + :keyword request_metadata: Required. The request metadata. + :paramtype request_metadata: ~azure.mgmt.hybridnetwork.models.RequestMetadata + """ + super(ExecuteRequestParameters, self).__init__(**kwargs) + self.service_endpoint = service_endpoint + self.request_metadata = request_metadata + + class ImageReference(msrest.serialization.Model): """The image reference properties. - :param publisher: The image publisher. - :type publisher: str - :param offer: Specifies the offer of the image used to create the virtual machine. - :type offer: str - :param sku: The image SKU. - :type sku: str - :param version: Specifies the version of the image used to create the virtual machine. The + :ivar publisher: The image publisher. + :vartype publisher: str + :ivar offer: Specifies the offer of the image used to create the virtual machine. + :vartype offer: str + :ivar sku: The image SKU. + :vartype sku: str + :ivar version: Specifies the version of the image used to create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image available at deploy time. Even if you use 'latest', the VM image will not automatically update after deploy time even if a new version becomes available. - :type version: str - :param exact_version: Specifies in decimal numbers, the exact version of image used to create + :vartype version: str + :ivar exact_version: Specifies in decimal numbers, the exact version of image used to create the virtual machine. - :type exact_version: str + :vartype exact_version: str """ _attribute_map = { @@ -482,6 +607,23 @@ def __init__( exact_version: Optional[str] = None, **kwargs ): + """ + :keyword publisher: The image publisher. + :paramtype publisher: str + :keyword offer: Specifies the offer of the image used to create the virtual machine. + :paramtype offer: str + :keyword sku: The image SKU. + :paramtype sku: str + :keyword version: Specifies the version of the image used to create the virtual machine. The + allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. + Specify 'latest' to use the latest version of an image available at deploy time. Even if you + use 'latest', the VM image will not automatically update after deploy time even if a new + version becomes available. + :paramtype version: str + :keyword exact_version: Specifies in decimal numbers, the exact version of image used to create + the virtual machine. + :paramtype exact_version: str + """ super(ImageReference, self).__init__(**kwargs) self.publisher = publisher self.offer = offer @@ -493,8 +635,8 @@ def __init__( class LinuxConfiguration(msrest.serialization.Model): """Specifies the Linux operating system settings on the virtual machine. - :param ssh: Specifies the ssh key configuration for a Linux OS. - :type ssh: ~hybrid_network_management_client.models.SshConfiguration + :ivar ssh: Specifies the ssh key configuration for a Linux OS. + :vartype ssh: ~azure.mgmt.hybridnetwork.models.SshConfiguration """ _attribute_map = { @@ -504,9 +646,13 @@ class LinuxConfiguration(msrest.serialization.Model): def __init__( self, *, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, **kwargs ): + """ + :keyword ssh: Specifies the ssh key configuration for a Linux OS. + :paramtype ssh: ~azure.mgmt.hybridnetwork.models.SshConfiguration + """ super(LinuxConfiguration, self).__init__(**kwargs) self.ssh = ssh @@ -526,44 +672,43 @@ class NetworkFunction(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: A unique read-only string that changes whenever the resource is updated. - :type etag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the network function resource. Possible - values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", - "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param device: The reference to the device resource. Once set, it cannot be updated. - :type device: ~hybrid_network_management_client.models.SubResource - :param sku_name: The sku name for the network function. Once set, it cannot be updated. - :type sku_name: str - :ivar sku_type: The sku type for the network function. Possible values include: "Unknown", + :vartype system_data: ~azure.mgmt.hybridnetwork.models.SystemData + :ivar provisioning_state: The provisioning state of the network function resource. Known values + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState + :ivar device: The reference to the device resource. Once set, it cannot be updated. + :vartype device: ~azure.mgmt.hybridnetwork.models.SubResource + :ivar sku_name: The sku name for the network function. Once set, it cannot be updated. + :vartype sku_name: str + :ivar sku_type: The sku type for the network function. Known values are: "Unknown", "EvolvedPacketCore", "SDWAN", "Firewall". - :vartype sku_type: str or ~hybrid_network_management_client.models.SkuType - :param vendor_name: The vendor name for the network function. Once set, it cannot be updated. - :type vendor_name: str + :vartype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType + :ivar vendor_name: The vendor name for the network function. Once set, it cannot be updated. + :vartype vendor_name: str :ivar service_key: The service key for the network function resource. :vartype service_key: str :ivar vendor_provisioning_state: The vendor provisioning state for the network function - resource. Possible values include: "Unknown", "NotProvisioned", "Provisioning", "Provisioned", + resource. Known values are: "Unknown", "NotProvisioned", "Provisioning", "Provisioned", "Deprovisioned", "UserDataValidationFailed". :vartype vendor_provisioning_state: str or - ~hybrid_network_management_client.models.VendorProvisioningState + ~azure.mgmt.hybridnetwork.models.VendorProvisioningState :ivar managed_application: The resource URI of the managed application. - :vartype managed_application: ~hybrid_network_management_client.models.SubResource - :param managed_application_parameters: The parameters for the managed application. - :type managed_application_parameters: any - :param network_function_container_configurations: The network function container configurations + :vartype managed_application: ~azure.mgmt.hybridnetwork.models.SubResource + :ivar managed_application_parameters: The parameters for the managed application. + :vartype managed_application_parameters: any + :ivar network_function_container_configurations: The network function container configurations from the user. - :type network_function_container_configurations: any - :param network_function_user_configurations: The network function configurations from the user. - :type network_function_user_configurations: - list[~hybrid_network_management_client.models.NetworkFunctionUserConfiguration] + :vartype network_function_container_configurations: any + :ivar network_function_user_configurations: The network function configurations from the user. + :vartype network_function_user_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkFunctionUserConfiguration] """ _validation = { @@ -606,14 +751,37 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - device: Optional["SubResource"] = None, + device: Optional["_models.SubResource"] = None, sku_name: Optional[str] = None, vendor_name: Optional[str] = None, managed_application_parameters: Optional[Any] = None, network_function_container_configurations: Optional[Any] = None, - network_function_user_configurations: Optional[List["NetworkFunctionUserConfiguration"]] = None, + network_function_user_configurations: Optional[List["_models.NetworkFunctionUserConfiguration"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword etag: A unique read-only string that changes whenever the resource is updated. + :paramtype etag: str + :keyword device: The reference to the device resource. Once set, it cannot be updated. + :paramtype device: ~azure.mgmt.hybridnetwork.models.SubResource + :keyword sku_name: The sku name for the network function. Once set, it cannot be updated. + :paramtype sku_name: str + :keyword vendor_name: The vendor name for the network function. Once set, it cannot be updated. + :paramtype vendor_name: str + :keyword managed_application_parameters: The parameters for the managed application. + :paramtype managed_application_parameters: any + :keyword network_function_container_configurations: The network function container + configurations from the user. + :paramtype network_function_container_configurations: any + :keyword network_function_user_configurations: The network function configurations from the + user. + :paramtype network_function_user_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkFunctionUserConfiguration] + """ super(NetworkFunction, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag self.system_data = None @@ -635,8 +803,8 @@ class NetworkFunctionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: A list of network function resources in a subscription or resource group. - :type value: list[~hybrid_network_management_client.models.NetworkFunction] + :ivar value: A list of network function resources in a subscription or resource group. + :vartype value: list[~azure.mgmt.hybridnetwork.models.NetworkFunction] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -653,9 +821,13 @@ class NetworkFunctionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["NetworkFunction"]] = None, + value: Optional[List["_models.NetworkFunction"]] = None, **kwargs ): + """ + :keyword value: A list of network function resources in a subscription or resource group. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.NetworkFunction] + """ super(NetworkFunctionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -664,35 +836,34 @@ def __init__( class NetworkFunctionRoleConfiguration(msrest.serialization.Model): """Network function role configuration. - :param role_name: The name of the network function role. - :type role_name: str - :param role_type: Role type. Possible values include: "Unknown", "VirtualMachine". - :type role_type: str or - ~hybrid_network_management_client.models.NetworkFunctionRoleConfigurationType - :param virtual_machine_size: The size of the virtual machine. Possible values include: - "Unknown", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", + :ivar role_name: The name of the network function role. + :vartype role_name: str + :ivar role_type: Role type. Known values are: "Unknown", "VirtualMachine". + :vartype role_type: str or + ~azure.mgmt.hybridnetwork.models.NetworkFunctionRoleConfigurationType + :ivar virtual_machine_size: The size of the virtual machine. Known values are: "Unknown", + "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", + "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_DS1_v2", "Standard_DS2_v2", + "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", "Standard_F16s". - :type virtual_machine_size: str or - ~hybrid_network_management_client.models.VirtualMachineSizeTypes - :param os_profile: Specifies the operating system settings for the role instance. This value - can be updated during the deployment of network function. - :type os_profile: ~hybrid_network_management_client.models.OsProfile - :param user_data_template: The user data template for customers. This is a json schema template + :vartype virtual_machine_size: str or ~azure.mgmt.hybridnetwork.models.VirtualMachineSizeTypes + :ivar os_profile: Specifies the operating system settings for the role instance. This value can + be updated during the deployment of network function. + :vartype os_profile: ~azure.mgmt.hybridnetwork.models.OsProfile + :ivar user_data_template: The user data template for customers. This is a json schema template describing the format and data type of user data parameters. - :type user_data_template: any - :param user_data_parameters: The user parameters for customers. The format of user data + :vartype user_data_template: any + :ivar user_data_parameters: The user parameters for customers. The format of user data parameters has to be matched with the provided user data template. - :type user_data_parameters: any - :param network_interfaces: The network interface configurations. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] - :param storage_profile: Specifies the storage settings for the virtual machine disks. - :type storage_profile: ~hybrid_network_management_client.models.StorageProfile - :param custom_profile: Specifies the custom settings for the virtual machine. - :type custom_profile: ~hybrid_network_management_client.models.CustomProfile + :vartype user_data_parameters: any + :ivar network_interfaces: The network interface configurations. + :vartype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] + :ivar storage_profile: Specifies the storage settings for the virtual machine disks. + :vartype storage_profile: ~azure.mgmt.hybridnetwork.models.StorageProfile + :ivar custom_profile: Specifies the custom settings for the virtual machine. + :vartype custom_profile: ~azure.mgmt.hybridnetwork.models.CustomProfile """ _attribute_map = { @@ -711,16 +882,47 @@ def __init__( self, *, role_name: Optional[str] = None, - role_type: Optional[Union[str, "NetworkFunctionRoleConfigurationType"]] = None, - virtual_machine_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, - os_profile: Optional["OsProfile"] = None, + role_type: Optional[Union[str, "_models.NetworkFunctionRoleConfigurationType"]] = None, + virtual_machine_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, + os_profile: Optional["_models.OsProfile"] = None, user_data_template: Optional[Any] = None, user_data_parameters: Optional[Any] = None, - network_interfaces: Optional[List["NetworkInterface"]] = None, - storage_profile: Optional["StorageProfile"] = None, - custom_profile: Optional["CustomProfile"] = None, + network_interfaces: Optional[List["_models.NetworkInterface"]] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + custom_profile: Optional["_models.CustomProfile"] = None, **kwargs ): + """ + :keyword role_name: The name of the network function role. + :paramtype role_name: str + :keyword role_type: Role type. Known values are: "Unknown", "VirtualMachine". + :paramtype role_type: str or + ~azure.mgmt.hybridnetwork.models.NetworkFunctionRoleConfigurationType + :keyword virtual_machine_size: The size of the virtual machine. Known values are: "Unknown", + "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", + "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_DS1_v2", "Standard_DS2_v2", + "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", + "Standard_DS12_v2", "Standard_DS13_v2", "Standard_F1", "Standard_F2", "Standard_F4", + "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", + "Standard_F16s". + :paramtype virtual_machine_size: str or + ~azure.mgmt.hybridnetwork.models.VirtualMachineSizeTypes + :keyword os_profile: Specifies the operating system settings for the role instance. This value + can be updated during the deployment of network function. + :paramtype os_profile: ~azure.mgmt.hybridnetwork.models.OsProfile + :keyword user_data_template: The user data template for customers. This is a json schema + template describing the format and data type of user data parameters. + :paramtype user_data_template: any + :keyword user_data_parameters: The user parameters for customers. The format of user data + parameters has to be matched with the provided user data template. + :paramtype user_data_parameters: any + :keyword network_interfaces: The network interface configurations. + :paramtype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] + :keyword storage_profile: Specifies the storage settings for the virtual machine disks. + :paramtype storage_profile: ~azure.mgmt.hybridnetwork.models.StorageProfile + :keyword custom_profile: Specifies the custom settings for the virtual machine. + :paramtype custom_profile: ~azure.mgmt.hybridnetwork.models.CustomProfile + """ super(NetworkFunctionRoleConfiguration, self).__init__(**kwargs) self.role_name = role_name self.role_type = role_type @@ -739,7 +941,7 @@ class NetworkFunctionRoleInstanceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: A list of role instances. - :vartype value: list[~hybrid_network_management_client.models.RoleInstance] + :vartype value: list[~azure.mgmt.hybridnetwork.models.RoleInstance] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -758,6 +960,8 @@ def __init__( self, **kwargs ): + """ + """ super(NetworkFunctionRoleInstanceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -768,11 +972,11 @@ class NetworkFunctionSkuDetails(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param sku_type: The network function sku type. Possible values include: "Unknown", + :ivar sku_type: The network function sku type. Known values are: "Unknown", "EvolvedPacketCore", "SDWAN", "Firewall". - :type sku_type: str or ~hybrid_network_management_client.models.SkuType - :param value: The network function sku role details. - :type value: list[~hybrid_network_management_client.models.NetworkFunctionSkuRoleDetails] + :vartype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType + :ivar value: The network function sku role details. + :vartype value: list[~azure.mgmt.hybridnetwork.models.NetworkFunctionSkuRoleDetails] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -790,10 +994,17 @@ class NetworkFunctionSkuDetails(msrest.serialization.Model): def __init__( self, *, - sku_type: Optional[Union[str, "SkuType"]] = None, - value: Optional[List["NetworkFunctionSkuRoleDetails"]] = None, + sku_type: Optional[Union[str, "_models.SkuType"]] = None, + value: Optional[List["_models.NetworkFunctionSkuRoleDetails"]] = None, **kwargs ): + """ + :keyword sku_type: The network function sku type. Known values are: "Unknown", + "EvolvedPacketCore", "SDWAN", "Firewall". + :paramtype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType + :keyword value: The network function sku role details. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.NetworkFunctionSkuRoleDetails] + """ super(NetworkFunctionSkuDetails, self).__init__(**kwargs) self.sku_type = sku_type self.value = value @@ -805,8 +1016,8 @@ class NetworkFunctionSkuListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The network function vendor sku overview properties. - :type value: list[~hybrid_network_management_client.models.SkuOverview] + :ivar value: The network function vendor sku overview properties. + :vartype value: list[~azure.mgmt.hybridnetwork.models.SkuOverview] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -823,9 +1034,13 @@ class NetworkFunctionSkuListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SkuOverview"]] = None, + value: Optional[List["_models.SkuOverview"]] = None, **kwargs ): + """ + :keyword value: The network function vendor sku overview properties. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.SkuOverview] + """ super(NetworkFunctionSkuListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -834,14 +1049,14 @@ def __init__( class NetworkFunctionSkuRoleDetails(msrest.serialization.Model): """The network function user configuration. - :param role_name: The name of the network function role. - :type role_name: str - :param user_data_template: The user data template for customers. - :type user_data_template: any - :param user_data_parameters: The user parameters for customers. - :type user_data_parameters: any - :param network_interfaces: The network interface configuration. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] + :ivar role_name: The name of the network function role. + :vartype role_name: str + :ivar user_data_template: The user data template for customers. + :vartype user_data_template: any + :ivar user_data_parameters: The user parameters for customers. + :vartype user_data_parameters: any + :ivar network_interfaces: The network interface configuration. + :vartype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] """ _attribute_map = { @@ -857,9 +1072,19 @@ def __init__( role_name: Optional[str] = None, user_data_template: Optional[Any] = None, user_data_parameters: Optional[Any] = None, - network_interfaces: Optional[List["NetworkInterface"]] = None, + network_interfaces: Optional[List["_models.NetworkInterface"]] = None, **kwargs ): + """ + :keyword role_name: The name of the network function role. + :paramtype role_name: str + :keyword user_data_template: The user data template for customers. + :paramtype user_data_template: any + :keyword user_data_parameters: The user parameters for customers. + :paramtype user_data_parameters: any + :keyword network_interfaces: The network interface configuration. + :paramtype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] + """ super(NetworkFunctionSkuRoleDetails, self).__init__(**kwargs) self.role_name = role_name self.user_data_template = user_data_template @@ -870,9 +1095,9 @@ def __init__( class NetworkFunctionTemplate(msrest.serialization.Model): """The network function template. - :param network_function_role_configurations: An array of network function role definitions. - :type network_function_role_configurations: - list[~hybrid_network_management_client.models.NetworkFunctionRoleConfiguration] + :ivar network_function_role_configurations: An array of network function role definitions. + :vartype network_function_role_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkFunctionRoleConfiguration] """ _attribute_map = { @@ -882,9 +1107,14 @@ class NetworkFunctionTemplate(msrest.serialization.Model): def __init__( self, *, - network_function_role_configurations: Optional[List["NetworkFunctionRoleConfiguration"]] = None, + network_function_role_configurations: Optional[List["_models.NetworkFunctionRoleConfiguration"]] = None, **kwargs ): + """ + :keyword network_function_role_configurations: An array of network function role definitions. + :paramtype network_function_role_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkFunctionRoleConfiguration] + """ super(NetworkFunctionTemplate, self).__init__(**kwargs) self.network_function_role_configurations = network_function_role_configurations @@ -892,15 +1122,14 @@ def __init__( class NetworkFunctionUserConfiguration(msrest.serialization.Model): """The network function user configuration. - :param role_name: The name of the network function role. - :type role_name: str - :param user_data_parameters: The user data parameters from the customer. - :type user_data_parameters: any - :param network_interfaces: The network interface configuration. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] - :param os_profile: Specifies the operating system settings for the role instance. - :type os_profile: - ~hybrid_network_management_client.models.NetworkFunctionUserConfigurationOsProfile + :ivar role_name: The name of the network function role. + :vartype role_name: str + :ivar user_data_parameters: The user data parameters from the customer. + :vartype user_data_parameters: any + :ivar network_interfaces: The network interface configuration. + :vartype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] + :ivar os_profile: Specifies the operating system settings for the role instance. + :vartype os_profile: ~azure.mgmt.hybridnetwork.models.NetworkFunctionUserConfigurationOsProfile """ _attribute_map = { @@ -915,10 +1144,21 @@ def __init__( *, role_name: Optional[str] = None, user_data_parameters: Optional[Any] = None, - network_interfaces: Optional[List["NetworkInterface"]] = None, - os_profile: Optional["NetworkFunctionUserConfigurationOsProfile"] = None, + network_interfaces: Optional[List["_models.NetworkInterface"]] = None, + os_profile: Optional["_models.NetworkFunctionUserConfigurationOsProfile"] = None, **kwargs ): + """ + :keyword role_name: The name of the network function role. + :paramtype role_name: str + :keyword user_data_parameters: The user data parameters from the customer. + :paramtype user_data_parameters: any + :keyword network_interfaces: The network interface configuration. + :paramtype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] + :keyword os_profile: Specifies the operating system settings for the role instance. + :paramtype os_profile: + ~azure.mgmt.hybridnetwork.models.NetworkFunctionUserConfigurationOsProfile + """ super(NetworkFunctionUserConfiguration, self).__init__(**kwargs) self.role_name = role_name self.user_data_parameters = user_data_parameters @@ -929,7 +1169,7 @@ def __init__( class NetworkFunctionUserConfigurationOsProfile(msrest.serialization.Model): """Specifies the operating system settings for the role instance. - :param custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded string is decoded to a binary array that is saved as a file on the virtual machine. The maximum length of the binary array is 65535 bytes. :code:`
    `:code:`
    ` **Note: Do not pass any secrets or passwords in customData property** :code:`
    `:code:`
    ` This property cannot be @@ -939,7 +1179,7 @@ class NetworkFunctionUserConfigurationOsProfile(msrest.serialization.Model): :code:`
    `:code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during creation `_. - :type custom_data: str + :vartype custom_data: str """ _attribute_map = { @@ -952,6 +1192,19 @@ def __init__( custom_data: Optional[str] = None, **kwargs ): + """ + :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + string is decoded to a binary array that is saved as a file on the virtual machine. The maximum + length of the binary array is 65535 bytes. :code:`
    `:code:`
    ` **Note: Do not pass any + secrets or passwords in customData property** :code:`
    `:code:`
    ` This property cannot be + updated after the VM is created. :code:`
    `:code:`
    ` customData is passed to the VM to be + saved as a file. For more information see `Custom Data on Azure VMs + `_ + :code:`
    `:code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to + customize a Linux VM during creation + `_. + :paramtype custom_data: str + """ super(NetworkFunctionUserConfigurationOsProfile, self).__init__(**kwargs) self.custom_data = custom_data @@ -959,10 +1212,10 @@ def __init__( class NetworkFunctionVendor(msrest.serialization.Model): """The network function vendor. - :param vendor_name: The network function vendor name. - :type vendor_name: str - :param sku_list: The network function sku list. - :type sku_list: list[~hybrid_network_management_client.models.SkuOverview] + :ivar vendor_name: The network function vendor name. + :vartype vendor_name: str + :ivar sku_list: The network function sku list. + :vartype sku_list: list[~azure.mgmt.hybridnetwork.models.SkuOverview] """ _attribute_map = { @@ -974,9 +1227,15 @@ def __init__( self, *, vendor_name: Optional[str] = None, - sku_list: Optional[List["SkuOverview"]] = None, + sku_list: Optional[List["_models.SkuOverview"]] = None, **kwargs ): + """ + :keyword vendor_name: The network function vendor name. + :paramtype vendor_name: str + :keyword sku_list: The network function sku list. + :paramtype sku_list: list[~azure.mgmt.hybridnetwork.models.SkuOverview] + """ super(NetworkFunctionVendor, self).__init__(**kwargs) self.vendor_name = vendor_name self.sku_list = sku_list @@ -987,14 +1246,14 @@ class NetworkFunctionVendorConfiguration(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param role_name: The name of the vendor network function role. - :type role_name: str - :param os_profile: Specifies the operating system settings for the role instance. - :type os_profile: ~hybrid_network_management_client.models.OsProfile + :ivar role_name: The name of the vendor network function role. + :vartype role_name: str + :ivar os_profile: Specifies the operating system settings for the role instance. + :vartype os_profile: ~azure.mgmt.hybridnetwork.models.OsProfile :ivar user_data_parameters: The user parameters from the customer. :vartype user_data_parameters: any - :param network_interfaces: The network interface configurations. - :type network_interfaces: list[~hybrid_network_management_client.models.NetworkInterface] + :ivar network_interfaces: The network interface configurations. + :vartype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] """ _validation = { @@ -1012,10 +1271,18 @@ def __init__( self, *, role_name: Optional[str] = None, - os_profile: Optional["OsProfile"] = None, - network_interfaces: Optional[List["NetworkInterface"]] = None, + os_profile: Optional["_models.OsProfile"] = None, + network_interfaces: Optional[List["_models.NetworkInterface"]] = None, **kwargs ): + """ + :keyword role_name: The name of the vendor network function role. + :paramtype role_name: str + :keyword os_profile: Specifies the operating system settings for the role instance. + :paramtype os_profile: ~azure.mgmt.hybridnetwork.models.OsProfile + :keyword network_interfaces: The network interface configurations. + :paramtype network_interfaces: list[~azure.mgmt.hybridnetwork.models.NetworkInterface] + """ super(NetworkFunctionVendorConfiguration, self).__init__(**kwargs) self.role_name = role_name self.os_profile = os_profile @@ -1028,8 +1295,8 @@ class NetworkFunctionVendorListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: A list of available network function vendors and skus. - :type value: list[~hybrid_network_management_client.models.NetworkFunctionVendor] + :ivar value: A list of available network function vendors and skus. + :vartype value: list[~azure.mgmt.hybridnetwork.models.NetworkFunctionVendor] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -1046,9 +1313,13 @@ class NetworkFunctionVendorListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["NetworkFunctionVendor"]] = None, + value: Optional[List["_models.NetworkFunctionVendor"]] = None, **kwargs ): + """ + :keyword value: A list of available network function vendors and skus. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.NetworkFunctionVendor] + """ super(NetworkFunctionVendorListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1057,16 +1328,16 @@ def __init__( class NetworkInterface(msrest.serialization.Model): """Network interface properties. - :param network_interface_name: The name of the network interface. - :type network_interface_name: str - :param mac_address: The MAC address of the network interface. - :type mac_address: str - :param ip_configurations: A list of IP configurations of the network interface. - :type ip_configurations: - list[~hybrid_network_management_client.models.NetworkInterfaceIPConfiguration] - :param vm_switch_type: The type of the VM switch. Possible values include: "Unknown", - "Management", "Wan", "Lan". - :type vm_switch_type: str or ~hybrid_network_management_client.models.VMSwitchType + :ivar network_interface_name: The name of the network interface. + :vartype network_interface_name: str + :ivar mac_address: The MAC address of the network interface. + :vartype mac_address: str + :ivar ip_configurations: A list of IP configurations of the network interface. + :vartype ip_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkInterfaceIPConfiguration] + :ivar vm_switch_type: The type of the VM switch. Known values are: "Unknown", "Management", + "Wan", "Lan". + :vartype vm_switch_type: str or ~azure.mgmt.hybridnetwork.models.VMSwitchType """ _attribute_map = { @@ -1081,10 +1352,22 @@ def __init__( *, network_interface_name: Optional[str] = None, mac_address: Optional[str] = None, - ip_configurations: Optional[List["NetworkInterfaceIPConfiguration"]] = None, - vm_switch_type: Optional[Union[str, "VMSwitchType"]] = None, + ip_configurations: Optional[List["_models.NetworkInterfaceIPConfiguration"]] = None, + vm_switch_type: Optional[Union[str, "_models.VMSwitchType"]] = None, **kwargs ): + """ + :keyword network_interface_name: The name of the network interface. + :paramtype network_interface_name: str + :keyword mac_address: The MAC address of the network interface. + :paramtype mac_address: str + :keyword ip_configurations: A list of IP configurations of the network interface. + :paramtype ip_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkInterfaceIPConfiguration] + :keyword vm_switch_type: The type of the VM switch. Known values are: "Unknown", "Management", + "Wan", "Lan". + :paramtype vm_switch_type: str or ~azure.mgmt.hybridnetwork.models.VMSwitchType + """ super(NetworkInterface, self).__init__(**kwargs) self.network_interface_name = network_interface_name self.mac_address = mac_address @@ -1095,19 +1378,19 @@ def __init__( class NetworkInterfaceIPConfiguration(msrest.serialization.Model): """Network interface IP configuration properties. - :param ip_allocation_method: IP address allocation method. Possible values include: "Unknown", + :ivar ip_allocation_method: IP address allocation method. Known values are: "Unknown", "Static", "Dynamic". - :type ip_allocation_method: str or ~hybrid_network_management_client.models.IPAllocationMethod - :param ip_address: The value of the IP address. - :type ip_address: str - :param subnet: The value of the subnet. - :type subnet: str - :param gateway: The value of the gateway. - :type gateway: str - :param ip_version: IP address version. Possible values include: "Unknown", "IPv4". - :type ip_version: str or ~hybrid_network_management_client.models.IPVersion - :param dns_servers: The list of DNS servers IP addresses. - :type dns_servers: list[str] + :vartype ip_allocation_method: str or ~azure.mgmt.hybridnetwork.models.IPAllocationMethod + :ivar ip_address: The value of the IP address. + :vartype ip_address: str + :ivar subnet: The value of the subnet. + :vartype subnet: str + :ivar gateway: The value of the gateway. + :vartype gateway: str + :ivar ip_version: IP address version. Known values are: "Unknown", "IPv4". + :vartype ip_version: str or ~azure.mgmt.hybridnetwork.models.IPVersion + :ivar dns_servers: The list of DNS servers IP addresses. + :vartype dns_servers: list[str] """ _attribute_map = { @@ -1122,14 +1405,29 @@ class NetworkInterfaceIPConfiguration(msrest.serialization.Model): def __init__( self, *, - ip_allocation_method: Optional[Union[str, "IPAllocationMethod"]] = None, + ip_allocation_method: Optional[Union[str, "_models.IPAllocationMethod"]] = None, ip_address: Optional[str] = None, subnet: Optional[str] = None, gateway: Optional[str] = None, - ip_version: Optional[Union[str, "IPVersion"]] = None, + ip_version: Optional[Union[str, "_models.IPVersion"]] = None, dns_servers: Optional[List[str]] = None, **kwargs ): + """ + :keyword ip_allocation_method: IP address allocation method. Known values are: "Unknown", + "Static", "Dynamic". + :paramtype ip_allocation_method: str or ~azure.mgmt.hybridnetwork.models.IPAllocationMethod + :keyword ip_address: The value of the IP address. + :paramtype ip_address: str + :keyword subnet: The value of the subnet. + :paramtype subnet: str + :keyword gateway: The value of the gateway. + :paramtype gateway: str + :keyword ip_version: IP address version. Known values are: "Unknown", "IPv4". + :paramtype ip_version: str or ~azure.mgmt.hybridnetwork.models.IPVersion + :keyword dns_servers: The list of DNS servers IP addresses. + :paramtype dns_servers: list[str] + """ super(NetworkInterfaceIPConfiguration, self).__init__(**kwargs) self.ip_allocation_method = ip_allocation_method self.ip_address = ip_address @@ -1140,49 +1438,86 @@ def __init__( class Operation(msrest.serialization.Model): - """Object that describes a single Microsoft.HybridNetwork operation. + """Details of a REST API operation, returned from the Resource Provider Operations API. Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: Operation name: {provider}/{resource}/{operation}. + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". :vartype name: str - :ivar display: The object that represents the operation. - :vartype display: ~hybrid_network_management_client.models.OperationDisplay + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.hybridnetwork.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.hybridnetwork.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.hybridnetwork.models.ActionType """ _validation = { 'name': {'readonly': True}, - 'display': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, } _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } def __init__( self, + *, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.hybridnetwork.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None - self.display = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.HybridNetwork. - :type provider: str - :param resource: Resource on which the operation is performed: Registration definition, - registration assignment, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str """ + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + _attribute_map = { 'provider': {'key': 'provider', 'type': 'str'}, 'resource': {'key': 'resource', 'type': 'str'}, @@ -1192,28 +1527,25 @@ class OperationDisplay(msrest.serialization.Model): def __init__( self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description + self.provider = None + self.resource = None + self.operation = None + self.description = None -class OperationList(msrest.serialization.Model): - """A list of the operations. +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: A list of Microsoft.HybridNetwork operations. - :vartype value: list[~hybrid_network_management_client.models.Operation] - :ivar next_link: The URL to get the next set of results. + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.hybridnetwork.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). :vartype next_link: str """ @@ -1231,7 +1563,9 @@ def __init__( self, **kwargs ): - super(OperationList, self).__init__(**kwargs) + """ + """ + super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1239,16 +1573,16 @@ def __init__( class OsDisk(msrest.serialization.Model): """Specifies information about the operating system disk used by the virtual machine. :code:`
    `:code:`
    ` For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :param os_type: The OS type. Possible values include: "Unknown", "Windows", "Linux". - :type os_type: str or ~hybrid_network_management_client.models.OperatingSystemTypes - :param name: The VHD name. - :type name: str - :param vhd: The virtual hard disk. - :type vhd: ~hybrid_network_management_client.models.VirtualHardDisk - :param disk_size_gb: Specifies the size of os disk in gigabytes. This is the fully expanded - disk size needed of the VHD image on the ASE. This disk size should be greater than the size of - the VHD provided in vhdUri. - :type disk_size_gb: int + :ivar os_type: The OS type. Known values are: "Unknown", "Windows", "Linux". + :vartype os_type: str or ~azure.mgmt.hybridnetwork.models.OperatingSystemTypes + :ivar name: The VHD name. + :vartype name: str + :ivar vhd: The virtual hard disk. + :vartype vhd: ~azure.mgmt.hybridnetwork.models.VirtualHardDisk + :ivar disk_size_gb: Specifies the size of os disk in gigabytes. This is the fully expanded disk + size needed of the VHD image on the ASE. This disk size should be greater than the size of the + VHD provided in vhdUri. + :vartype disk_size_gb: int """ _attribute_map = { @@ -1261,12 +1595,24 @@ class OsDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, disk_size_gb: Optional[int] = None, **kwargs ): + """ + :keyword os_type: The OS type. Known values are: "Unknown", "Windows", "Linux". + :paramtype os_type: str or ~azure.mgmt.hybridnetwork.models.OperatingSystemTypes + :keyword name: The VHD name. + :paramtype name: str + :keyword vhd: The virtual hard disk. + :paramtype vhd: ~azure.mgmt.hybridnetwork.models.VirtualHardDisk + :keyword disk_size_gb: Specifies the size of os disk in gigabytes. This is the fully expanded + disk size needed of the VHD image on the ASE. This disk size should be greater than the size of + the VHD provided in vhdUri. + :paramtype disk_size_gb: int + """ super(OsDisk, self).__init__(**kwargs) self.os_type = os_type self.name = name @@ -1277,30 +1623,29 @@ def __init__( class OsProfile(msrest.serialization.Model): """Specifies the operating system settings for the role instance. - :param admin_username: Specifies the name of the administrator account. - :code:`
    `:code:`
    ` **Windows-only restriction:** Cannot end in "." - :code:`
    `:code:`
    ` **Disallowed values:** "administrator", "admin", "user", "user1", - "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", - "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", - "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". - :code:`
    `:code:`
    ` **Minimum-length (Linux):** 1 character :code:`
    `:code:`
    ` - **Max-length (Linux):** 64 characters :code:`
    `:code:`
    ` **Max-length (Windows):** 20 - characters :code:`
    `:code:`
    `:code:`
  • ` For root access to the Linux VM, see `Using - root privileges on Linux virtual machines in Azure + :ivar admin_username: Specifies the name of the administrator account. :code:`
    `:code:`
    ` + **Windows-only restriction:** Cannot end in "." :code:`
    `:code:`
    ` **Disallowed values:** + "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", + "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", + "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", + "test3", "user4", "user5". :code:`
    `:code:`
    ` **Minimum-length (Linux):** 1 character + :code:`
    `:code:`
    ` **Max-length (Linux):** 64 characters :code:`
    `:code:`
    ` + **Max-length (Windows):** 20 characters :code:`
    `:code:`
    `:code:`
  • ` For root access + to the Linux VM, see `Using root privileges on Linux virtual machines in Azure `_\ :code:`
    `:code:`
  • ` For a list of built-in system users on Linux that should not be used in this field, see `Selecting User Names for Linux on Azure `_. - :type admin_username: str - :param linux_configuration: Specifies the Linux operating system settings on the virtual + :vartype admin_username: str + :ivar linux_configuration: Specifies the Linux operating system settings on the virtual machine. :code:`
    `:code:`
    `For a list of supported Linux distributions, see `Linux on Azure-Endorsed Distributions `_ :code:`
    `:code:`
    ` For running non-endorsed distributions, see `Information for Non-Endorsed Distributions `_. - :type linux_configuration: ~hybrid_network_management_client.models.LinuxConfiguration - :param custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + :vartype linux_configuration: ~azure.mgmt.hybridnetwork.models.LinuxConfiguration + :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded string is decoded to a binary array that is saved as a file on the virtual machine. The maximum length of the binary array is 65535 bytes. :code:`
    `:code:`
    ` **Note: Do not pass any secrets or passwords in customData property** :code:`
    `:code:`
    ` This property cannot be @@ -1310,9 +1655,9 @@ class OsProfile(msrest.serialization.Model): :code:`
    `:code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during creation `_. - :type custom_data: str - :param custom_data_required: Indicates if custom data is required to deploy this role. - :type custom_data_required: bool + :vartype custom_data: str + :ivar custom_data_required: Indicates if custom data is required to deploy this role. + :vartype custom_data_required: bool """ _attribute_map = { @@ -1326,11 +1671,49 @@ def __init__( self, *, admin_username: Optional[str] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, custom_data: Optional[str] = None, custom_data_required: Optional[bool] = True, **kwargs ): + """ + :keyword admin_username: Specifies the name of the administrator account. + :code:`
    `:code:`
    ` **Windows-only restriction:** Cannot end in "." + :code:`
    `:code:`
    ` **Disallowed values:** "administrator", "admin", "user", "user1", + "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", + "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", + "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". + :code:`
    `:code:`
    ` **Minimum-length (Linux):** 1 character :code:`
    `:code:`
    ` + **Max-length (Linux):** 64 characters :code:`
    `:code:`
    ` **Max-length (Windows):** 20 + characters :code:`
    `:code:`
    `:code:`
  • ` For root access to the Linux VM, see `Using + root privileges on Linux virtual machines in Azure + `_\ + :code:`
    `:code:`
  • ` For a list of built-in system users on Linux that should not be used + in this field, see `Selecting User Names for Linux on Azure + `_. + :paramtype admin_username: str + :keyword linux_configuration: Specifies the Linux operating system settings on the virtual + machine. :code:`
    `:code:`
    `For a list of supported Linux distributions, see `Linux on + Azure-Endorsed Distributions + `_ + :code:`
    `:code:`
    ` For running non-endorsed distributions, see `Information for + Non-Endorsed Distributions + `_. + :paramtype linux_configuration: ~azure.mgmt.hybridnetwork.models.LinuxConfiguration + :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + string is decoded to a binary array that is saved as a file on the virtual machine. The maximum + length of the binary array is 65535 bytes. :code:`
    `:code:`
    ` **Note: Do not pass any + secrets or passwords in customData property** :code:`
    `:code:`
    ` This property cannot be + updated after the VM is created. :code:`
    `:code:`
    ` customData is passed to the VM to be + saved as a file. For more information see `Custom Data on Azure VMs + `_ + :code:`
    `:code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to + customize a Linux VM during creation + `_. + :paramtype custom_data: str + :keyword custom_data_required: Indicates if custom data is required to deploy this role. + :paramtype custom_data_required: bool + """ super(OsProfile, self).__init__(**kwargs) self.admin_username = admin_username self.linux_configuration = linux_configuration @@ -1350,11 +1733,10 @@ class PreviewSubscription(msrest.serialization.Model): :ivar type: The type of the resource. :vartype type: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the PreviewSubscription resource. Possible - values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", - "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState + :vartype system_data: ~azure.mgmt.hybridnetwork.models.SystemData + :ivar provisioning_state: The provisioning state of the PreviewSubscription resource. Known + values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState """ _validation = { @@ -1377,6 +1759,8 @@ def __init__( self, **kwargs ): + """ + """ super(PreviewSubscription, self).__init__(**kwargs) self.name = None self.id = None @@ -1390,8 +1774,8 @@ class PreviewSubscriptionsList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: A list of preview subscriptions. - :type value: list[~hybrid_network_management_client.models.PreviewSubscription] + :ivar value: A list of preview subscriptions. + :vartype value: list[~azure.mgmt.hybridnetwork.models.PreviewSubscription] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -1408,9 +1792,13 @@ class PreviewSubscriptionsList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PreviewSubscription"]] = None, + value: Optional[List["_models.PreviewSubscription"]] = None, **kwargs ): + """ + :keyword value: A list of preview subscriptions. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.PreviewSubscription] + """ super(PreviewSubscriptionsList, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1447,28 +1835,86 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) +class RequestMetadata(msrest.serialization.Model): + """Request metadata of execute request post call payload. + + All required parameters must be populated in order to send to Azure. + + :ivar relative_path: Required. The relative path of the request. + :vartype relative_path: str + :ivar http_method: Required. The http method of the request. Known values are: "Unknown", + "Post", "Put", "Get", "Patch", "Delete". + :vartype http_method: str or ~azure.mgmt.hybridnetwork.models.HttpMethod + :ivar serialized_body: Required. The serialized body of the request. + :vartype serialized_body: str + :ivar api_version: The api version of the request. + :vartype api_version: str + """ + + _validation = { + 'relative_path': {'required': True}, + 'http_method': {'required': True}, + 'serialized_body': {'required': True}, + } + + _attribute_map = { + 'relative_path': {'key': 'relativePath', 'type': 'str'}, + 'http_method': {'key': 'httpMethod', 'type': 'str'}, + 'serialized_body': {'key': 'serializedBody', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + relative_path: str, + http_method: Union[str, "_models.HttpMethod"], + serialized_body: str, + api_version: Optional[str] = None, + **kwargs + ): + """ + :keyword relative_path: Required. The relative path of the request. + :paramtype relative_path: str + :keyword http_method: Required. The http method of the request. Known values are: "Unknown", + "Post", "Put", "Get", "Patch", "Delete". + :paramtype http_method: str or ~azure.mgmt.hybridnetwork.models.HttpMethod + :keyword serialized_body: Required. The serialized body of the request. + :paramtype serialized_body: str + :keyword api_version: The api version of the request. + :paramtype api_version: str + """ + super(RequestMetadata, self).__init__(**kwargs) + self.relative_path = relative_path + self.http_method = http_method + self.serialized_body = serialized_body + self.api_version = api_version + + class RoleInstance(msrest.serialization.Model): """The role instance sub resource. Variables are only populated by the server, and will be ignored when sending a request. - :param name: The role instance name. - :type name: str - :param id: The ARM ID of the resource. - :type id: str - :param type: The type of the resource. - :type type: str + :ivar name: The role instance name. + :vartype name: str + :ivar id: The ARM ID of the resource. + :vartype id: str + :ivar type: The type of the resource. + :vartype type: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the RoleInstance resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param operational_state: The operational state of the role instance. Possible values include: + :vartype system_data: ~azure.mgmt.hybridnetwork.models.SystemData + :ivar provisioning_state: The provisioning state of the RoleInstance resource. Known values + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState + :ivar operational_state: The operational state of the role instance. Known values are: "Unknown", "Stopped", "Running", "Stopping", "Starting". - :type operational_state: str or ~hybrid_network_management_client.models.OperationalState + :vartype operational_state: str or ~azure.mgmt.hybridnetwork.models.OperationalState """ _validation = { @@ -1491,9 +1937,20 @@ def __init__( name: Optional[str] = None, id: Optional[str] = None, type: Optional[str] = None, - operational_state: Optional[Union[str, "OperationalState"]] = None, + operational_state: Optional[Union[str, "_models.OperationalState"]] = None, **kwargs ): + """ + :keyword name: The role instance name. + :paramtype name: str + :keyword id: The ARM ID of the resource. + :paramtype id: str + :keyword type: The type of the resource. + :paramtype type: str + :keyword operational_state: The operational state of the role instance. Known values are: + "Unknown", "Stopped", "Running", "Stopping", "Starting". + :paramtype operational_state: str or ~azure.mgmt.hybridnetwork.models.OperationalState + """ super(RoleInstance, self).__init__(**kwargs) self.name = name self.id = id @@ -1503,14 +1960,67 @@ def __init__( self.operational_state = operational_state +class SkuCredential(msrest.serialization.Model): + """The Sku credential definition. + + :ivar username: The username of the sku credential. + :vartype username: str + :ivar acr_token: The credential value. + :vartype acr_token: str + :ivar acr_server_url: The Acr server url. + :vartype acr_server_url: str + :ivar repositories: The repositories that could be accessed using the current credential. + :vartype repositories: list[str] + :ivar expiry: The UTC time when credential will expire. + :vartype expiry: ~datetime.datetime + """ + + _attribute_map = { + 'username': {'key': 'username', 'type': 'str'}, + 'acr_token': {'key': 'acrToken', 'type': 'str'}, + 'acr_server_url': {'key': 'acrServerUrl', 'type': 'str'}, + 'repositories': {'key': 'repositories', 'type': '[str]'}, + 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + username: Optional[str] = None, + acr_token: Optional[str] = None, + acr_server_url: Optional[str] = None, + repositories: Optional[List[str]] = None, + expiry: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword username: The username of the sku credential. + :paramtype username: str + :keyword acr_token: The credential value. + :paramtype acr_token: str + :keyword acr_server_url: The Acr server url. + :paramtype acr_server_url: str + :keyword repositories: The repositories that could be accessed using the current credential. + :paramtype repositories: list[str] + :keyword expiry: The UTC time when credential will expire. + :paramtype expiry: ~datetime.datetime + """ + super(SkuCredential, self).__init__(**kwargs) + self.username = username + self.acr_token = acr_token + self.acr_server_url = acr_server_url + self.repositories = repositories + self.expiry = expiry + + class SkuOverview(msrest.serialization.Model): """The network function sku overview. - :param sku_name: The vendor sku name. - :type sku_name: str - :param sku_type: The vendor sku type. Possible values include: "Unknown", "EvolvedPacketCore", - "SDWAN", "Firewall". - :type sku_type: str or ~hybrid_network_management_client.models.SkuType + :ivar sku_name: The vendor sku name. + :vartype sku_name: str + :ivar sku_type: The vendor sku type. Known values are: "Unknown", "EvolvedPacketCore", "SDWAN", + "Firewall". + :vartype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType """ _attribute_map = { @@ -1522,9 +2032,16 @@ def __init__( self, *, sku_name: Optional[str] = None, - sku_type: Optional[Union[str, "SkuType"]] = None, + sku_type: Optional[Union[str, "_models.SkuType"]] = None, **kwargs ): + """ + :keyword sku_name: The vendor sku name. + :paramtype sku_name: str + :keyword sku_type: The vendor sku type. Known values are: "Unknown", "EvolvedPacketCore", + "SDWAN", "Firewall". + :paramtype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType + """ super(SkuOverview, self).__init__(**kwargs) self.sku_name = sku_name self.sku_type = sku_type @@ -1533,8 +2050,8 @@ def __init__( class SshConfiguration(msrest.serialization.Model): """SSH configuration for Linux based VMs running on Azure. - :param public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :type public_keys: list[~hybrid_network_management_client.models.SshPublicKey] + :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. + :vartype public_keys: list[~azure.mgmt.hybridnetwork.models.SshPublicKey] """ _attribute_map = { @@ -1544,9 +2061,13 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): + """ + :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. + :paramtype public_keys: list[~azure.mgmt.hybridnetwork.models.SshPublicKey] + """ super(SshConfiguration, self).__init__(**kwargs) self.public_keys = public_keys @@ -1554,15 +2075,15 @@ def __init__( class SshPublicKey(msrest.serialization.Model): """Contains information about SSH certificate public key and the path on the Linux VM where the public key is placed. - :param path: Specifies the full path on the created VM where ssh public key is stored. If the + :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the file already exists, the specified key is appended to the file. Example: /home/user/.ssh/authorized_keys. - :type path: str - :param key_data: SSH public key certificate used to authenticate with the VM through ssh. The + :vartype path: str + :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `:code:`
    ` For creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure `_. - :type key_data: str + :vartype key_data: str """ _attribute_map = { @@ -1577,6 +2098,17 @@ def __init__( key_data: Optional[str] = None, **kwargs ): + """ + :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the + file already exists, the specified key is appended to the file. Example: + /home/user/.ssh/authorized_keys. + :paramtype path: str + :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The + key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `:code:`
    ` For creating + ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure + `_. + :paramtype key_data: str + """ super(SshPublicKey, self).__init__(**kwargs) self.path = path self.key_data = key_data @@ -1585,14 +2117,14 @@ def __init__( class StorageProfile(msrest.serialization.Model): """Specifies the storage settings for the virtual machine disks. - :param image_reference: The image reference properties. - :type image_reference: ~hybrid_network_management_client.models.ImageReference - :param os_disk: Specifies information about the operating system disk used by the virtual + :ivar image_reference: The image reference properties. + :vartype image_reference: ~azure.mgmt.hybridnetwork.models.ImageReference + :ivar os_disk: Specifies information about the operating system disk used by the virtual machine. - :type os_disk: ~hybrid_network_management_client.models.OsDisk - :param data_disks: Specifies the parameters that are used to add a data disk to a virtual + :vartype os_disk: ~azure.mgmt.hybridnetwork.models.OsDisk + :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual machine. - :type data_disks: list[~hybrid_network_management_client.models.DataDisk] + :vartype data_disks: list[~azure.mgmt.hybridnetwork.models.DataDisk] """ _attribute_map = { @@ -1604,11 +2136,21 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OsDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OsDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): + """ + :keyword image_reference: The image reference properties. + :paramtype image_reference: ~azure.mgmt.hybridnetwork.models.ImageReference + :keyword os_disk: Specifies information about the operating system disk used by the virtual + machine. + :paramtype os_disk: ~azure.mgmt.hybridnetwork.models.OsDisk + :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual + machine. + :paramtype data_disks: list[~azure.mgmt.hybridnetwork.models.DataDisk] + """ super(StorageProfile, self).__init__(**kwargs) self.image_reference = image_reference self.os_disk = os_disk @@ -1618,8 +2160,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Reference to another sub resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1632,6 +2174,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1639,20 +2185,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~hybrid_network_management_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~hybrid_network_management_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.hybridnetwork.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.hybridnetwork.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1668,13 +2214,29 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.hybridnetwork.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.hybridnetwork.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -1687,8 +2249,8 @@ def __init__( class TagsObject(msrest.serialization.Model): """Tags object for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1701,6 +2263,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsObject, self).__init__(**kwargs) self.tags = tags @@ -1719,12 +2285,12 @@ class Vendor(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the vendor resource. Possible values - include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState + :vartype system_data: ~azure.mgmt.hybridnetwork.models.SystemData + :ivar provisioning_state: The provisioning state of the vendor resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState :ivar skus: A list of IDs of the vendor skus offered by the vendor. - :vartype skus: list[~hybrid_network_management_client.models.SubResource] + :vartype skus: list[~azure.mgmt.hybridnetwork.models.SubResource] """ _validation = { @@ -1749,6 +2315,8 @@ def __init__( self, **kwargs ): + """ + """ super(Vendor, self).__init__(**kwargs) self.system_data = None self.provisioning_state = None @@ -1760,8 +2328,8 @@ class VendorListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: A list of vendors. - :type value: list[~hybrid_network_management_client.models.Vendor] + :ivar value: A list of vendors. + :vartype value: list[~azure.mgmt.hybridnetwork.models.Vendor] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -1778,9 +2346,13 @@ class VendorListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Vendor"]] = None, + value: Optional[List["_models.Vendor"]] = None, **kwargs ): + """ + :keyword value: A list of vendors. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.Vendor] + """ super(VendorListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1800,25 +2372,25 @@ class VendorNetworkFunction(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData + :vartype system_data: ~azure.mgmt.hybridnetwork.models.SystemData :ivar provisioning_state: The provisioning state of the vendor network function sub resource. - Possible values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param vendor_provisioning_state: The vendor controlled provisioning state of the vendor - network function. Possible values include: "Unknown", "NotProvisioned", "Provisioning", - "Provisioned", "Deprovisioned", "UserDataValidationFailed". - :type vendor_provisioning_state: str or - ~hybrid_network_management_client.models.VendorProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState + :ivar vendor_provisioning_state: The vendor controlled provisioning state of the vendor network + function. Known values are: "Unknown", "NotProvisioned", "Provisioning", "Provisioned", + "Deprovisioned", "UserDataValidationFailed". + :vartype vendor_provisioning_state: str or + ~azure.mgmt.hybridnetwork.models.VendorProvisioningState :ivar sku_name: The name of the sku. Once set, it cannot be updated. :vartype sku_name: str - :ivar sku_type: The sku type. Possible values include: "Unknown", "EvolvedPacketCore", "SDWAN", + :ivar sku_type: The sku type. Known values are: "Unknown", "EvolvedPacketCore", "SDWAN", "Firewall". - :vartype sku_type: str or ~hybrid_network_management_client.models.SkuType - :param network_function_vendor_configurations: An array of network function vendor + :vartype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType + :ivar network_function_vendor_configurations: An array of network function vendor configurations. - :type network_function_vendor_configurations: - list[~hybrid_network_management_client.models.NetworkFunctionVendorConfiguration] + :vartype network_function_vendor_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkFunctionVendorConfiguration] """ _validation = { @@ -1846,10 +2418,21 @@ class VendorNetworkFunction(ProxyResource): def __init__( self, *, - vendor_provisioning_state: Optional[Union[str, "VendorProvisioningState"]] = None, - network_function_vendor_configurations: Optional[List["NetworkFunctionVendorConfiguration"]] = None, + vendor_provisioning_state: Optional[Union[str, "_models.VendorProvisioningState"]] = None, + network_function_vendor_configurations: Optional[List["_models.NetworkFunctionVendorConfiguration"]] = None, **kwargs ): + """ + :keyword vendor_provisioning_state: The vendor controlled provisioning state of the vendor + network function. Known values are: "Unknown", "NotProvisioned", "Provisioning", "Provisioned", + "Deprovisioned", "UserDataValidationFailed". + :paramtype vendor_provisioning_state: str or + ~azure.mgmt.hybridnetwork.models.VendorProvisioningState + :keyword network_function_vendor_configurations: An array of network function vendor + configurations. + :paramtype network_function_vendor_configurations: + list[~azure.mgmt.hybridnetwork.models.NetworkFunctionVendorConfiguration] + """ super(VendorNetworkFunction, self).__init__(**kwargs) self.system_data = None self.provisioning_state = None @@ -1864,8 +2447,8 @@ class VendorNetworkFunctionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: A list of vendor network functions. - :type value: list[~hybrid_network_management_client.models.VendorNetworkFunction] + :ivar value: A list of vendor network functions. + :vartype value: list[~azure.mgmt.hybridnetwork.models.VendorNetworkFunction] :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ @@ -1882,9 +2465,13 @@ class VendorNetworkFunctionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VendorNetworkFunction"]] = None, + value: Optional[List["_models.VendorNetworkFunction"]] = None, **kwargs ): + """ + :keyword value: A list of vendor network functions. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.VendorNetworkFunction] + """ super(VendorNetworkFunctionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1904,31 +2491,28 @@ class VendorSku(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~hybrid_network_management_client.models.SystemData - :ivar provisioning_state: The provisioning state of the vendor sku sub resource. Possible - values include: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", - "Deleted". - :vartype provisioning_state: str or ~hybrid_network_management_client.models.ProvisioningState - :param sku_type: The sku type. Possible values include: "Unknown", "EvolvedPacketCore", - "SDWAN", "Firewall". - :type sku_type: str or ~hybrid_network_management_client.models.SkuType - :param deployment_mode: The sku deployment mode. Possible values include: "Unknown", "Azure", + :vartype system_data: ~azure.mgmt.hybridnetwork.models.SystemData + :ivar provisioning_state: The provisioning state of the vendor sku sub resource. Known values + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridnetwork.models.ProvisioningState + :ivar sku_type: The sku type. Known values are: "Unknown", "EvolvedPacketCore", "SDWAN", + "Firewall". + :vartype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType + :ivar deployment_mode: The sku deployment mode. Known values are: "Unknown", "Azure", "PrivateEdgeZone". - :type deployment_mode: str or ~hybrid_network_management_client.models.SkuDeploymentMode - :param network_function_type: The network function type. Possible values include: "Unknown", + :vartype deployment_mode: str or ~azure.mgmt.hybridnetwork.models.SkuDeploymentMode + :ivar network_function_type: The network function type. Known values are: "Unknown", "VirtualNetworkFunction", "ContainerizedNetworkFunction". - :type network_function_type: str or - ~hybrid_network_management_client.models.NetworkFunctionType - :param preview: Indicates if the vendor sku is in preview mode. - :type preview: bool - :param managed_application_parameters: The parameters for the managed application to be - supplied by the vendor. - :type managed_application_parameters: any - :param managed_application_template: The template for the managed application deployment. - :type managed_application_template: any - :param network_function_template: The template definition of the network function. - :type network_function_template: - ~hybrid_network_management_client.models.NetworkFunctionTemplate + :vartype network_function_type: str or ~azure.mgmt.hybridnetwork.models.NetworkFunctionType + :ivar preview: Indicates if the vendor sku is in preview mode. + :vartype preview: bool + :ivar managed_application_parameters: The parameters for the managed application to be supplied + by the vendor. + :vartype managed_application_parameters: any + :ivar managed_application_template: The template for the managed application deployment. + :vartype managed_application_template: any + :ivar network_function_template: The template definition of the network function. + :vartype network_function_template: ~azure.mgmt.hybridnetwork.models.NetworkFunctionTemplate """ _validation = { @@ -1957,15 +2541,35 @@ class VendorSku(ProxyResource): def __init__( self, *, - sku_type: Optional[Union[str, "SkuType"]] = None, - deployment_mode: Optional[Union[str, "SkuDeploymentMode"]] = None, - network_function_type: Optional[Union[str, "NetworkFunctionType"]] = None, + sku_type: Optional[Union[str, "_models.SkuType"]] = None, + deployment_mode: Optional[Union[str, "_models.SkuDeploymentMode"]] = None, + network_function_type: Optional[Union[str, "_models.NetworkFunctionType"]] = None, preview: Optional[bool] = None, managed_application_parameters: Optional[Any] = None, managed_application_template: Optional[Any] = None, - network_function_template: Optional["NetworkFunctionTemplate"] = None, + network_function_template: Optional["_models.NetworkFunctionTemplate"] = None, **kwargs ): + """ + :keyword sku_type: The sku type. Known values are: "Unknown", "EvolvedPacketCore", "SDWAN", + "Firewall". + :paramtype sku_type: str or ~azure.mgmt.hybridnetwork.models.SkuType + :keyword deployment_mode: The sku deployment mode. Known values are: "Unknown", "Azure", + "PrivateEdgeZone". + :paramtype deployment_mode: str or ~azure.mgmt.hybridnetwork.models.SkuDeploymentMode + :keyword network_function_type: The network function type. Known values are: "Unknown", + "VirtualNetworkFunction", "ContainerizedNetworkFunction". + :paramtype network_function_type: str or ~azure.mgmt.hybridnetwork.models.NetworkFunctionType + :keyword preview: Indicates if the vendor sku is in preview mode. + :paramtype preview: bool + :keyword managed_application_parameters: The parameters for the managed application to be + supplied by the vendor. + :paramtype managed_application_parameters: any + :keyword managed_application_template: The template for the managed application deployment. + :paramtype managed_application_template: any + :keyword network_function_template: The template definition of the network function. + :paramtype network_function_template: ~azure.mgmt.hybridnetwork.models.NetworkFunctionTemplate + """ super(VendorSku, self).__init__(**kwargs) self.system_data = None self.provisioning_state = None @@ -1983,8 +2587,8 @@ class VendorSkuListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: A list of vendor skus offered by the vendor. - :type value: list[~hybrid_network_management_client.models.VendorSku] + :ivar value: A list of vendor skus offered by the vendor. + :vartype value: list[~azure.mgmt.hybridnetwork.models.VendorSku] :ivar next_link: The URI to get the next set of results. :vartype next_link: str """ @@ -2001,9 +2605,13 @@ class VendorSkuListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VendorSku"]] = None, + value: Optional[List["_models.VendorSku"]] = None, **kwargs ): + """ + :keyword value: A list of vendor skus offered by the vendor. + :paramtype value: list[~azure.mgmt.hybridnetwork.models.VendorSku] + """ super(VendorSkuListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2012,8 +2620,8 @@ def __init__( class VirtualHardDisk(msrest.serialization.Model): """Describes the uri of a disk. - :param uri: Specifies the virtual hard disk's uri. - :type uri: str + :ivar uri: Specifies the virtual hard disk's uri. + :vartype uri: str """ _attribute_map = { @@ -2026,5 +2634,9 @@ def __init__( uri: Optional[str] = None, **kwargs ): + """ + :keyword uri: Specifies the virtual hard disk's uri. + :paramtype uri: str + """ super(VirtualHardDisk, self).__init__(**kwargs) self.uri = uri diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_patch.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/__init__.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/__init__.py index ff21fc7723ce..0063fdc1cad4 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/__init__.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/__init__.py @@ -6,26 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._network_functions_operations import NetworkFunctionsOperations from ._devices_operations import DevicesOperations +from ._network_functions_operations import NetworkFunctionsOperations +from ._network_function_vendors_operations import NetworkFunctionVendorsOperations +from ._network_function_vendor_skus_operations import NetworkFunctionVendorSkusOperations from ._operations import Operations from ._vendors_operations import VendorsOperations from ._vendor_skus_operations import VendorSkusOperations from ._vendor_sku_preview_operations import VendorSkuPreviewOperations -from ._network_function_vendors_operations import NetworkFunctionVendorsOperations -from ._network_function_vendor_skus_operations import NetworkFunctionVendorSkusOperations from ._vendor_network_functions_operations import VendorNetworkFunctionsOperations from ._role_instances_operations import RoleInstancesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'NetworkFunctionsOperations', 'DevicesOperations', + 'NetworkFunctionsOperations', + 'NetworkFunctionVendorsOperations', + 'NetworkFunctionVendorSkusOperations', 'Operations', 'VendorsOperations', 'VendorSkusOperations', 'VendorSkuPreviewOperations', - 'NetworkFunctionVendorsOperations', - 'NetworkFunctionVendorSkusOperations', 'VendorNetworkFunctionsOperations', 'RoleInstancesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_devices_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_devices_operations.py index 4f698470ca1d..964eb09073d6 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_devices_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,371 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request_initial( + resource_group_name: str, + device_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + device_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + device_name: str, + subscription_id: str, + *, + json: Optional[_models.Device] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + device_name: str, + subscription_id: str, + *, + json: Optional[_models.TagsObject] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/devices") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices") # 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), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_registration_key_request( + resource_group_name: str, + device_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}/listRegistrationKey") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deviceName": _SERIALIZER.url("device_name", device_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DevicesOperations(object): - """DevicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - device_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - device_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified device. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -108,44 +379,52 @@ def begin_delete( :type device_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, device_name=device_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -154,17 +433,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - device_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Device" + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> _models.Device: """Gets information about the specified device. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -173,41 +452,43 @@ def get( :type device_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Device, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.Device + :rtype: ~azure.mgmt.hybridnetwork.models.Device :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] + + + request = build_get_request( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Device', pipeline_response) @@ -216,54 +497,55 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - device_name, # type: str - parameters, # type: "_models.Device" - **kwargs # type: Any - ): - # type: (...) -> "_models.Device" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] + resource_group_name: str, + device_name: str, + parameters: _models.Device, + **kwargs: Any + ) -> _models.Device: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Device') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] + + _json = self._serialize.body(parameters, 'Device') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Device', pipeline_response) @@ -275,16 +557,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - device_name, # type: str - parameters, # type: "_models.Device" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Device"] + resource_group_name: str, + device_name: str, + parameters: _models.Device, + **kwargs: Any + ) -> LROPoller[_models.Device]: """Creates or updates a device. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -292,51 +576,60 @@ def begin_create_or_update( :param device_name: Resource name for the device resource. :type device_name: str :param parameters: Parameters supplied to the create or update device operation. - :type parameters: ~hybrid_network_management_client.models.Device + :type parameters: ~azure.mgmt.hybridnetwork.models.Device :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. + :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. + :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 Device or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~hybrid_network_management_client.models.Device] - :raises ~azure.core.exceptions.HttpResponseError: + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridnetwork.models.Device] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, device_name=device_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Device', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -345,18 +638,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + @distributed_trace def update_tags( self, - resource_group_name, # type: str - device_name, # type: str - parameters, # type: "_models.TagsObject" - **kwargs # type: Any - ): - # type: (...) -> "_models.Device" + resource_group_name: str, + device_name: str, + parameters: _models.TagsObject, + **kwargs: Any + ) -> _models.Device: """Updates device tags. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -364,49 +657,50 @@ def update_tags( :param device_name: The name of the device resource. :type device_name: str :param parameters: Parameters supplied to the update device tags operation. - :type parameters: ~hybrid_network_management_client.models.TagsObject + :type parameters: ~azure.mgmt.hybridnetwork.models.TagsObject :keyword callable cls: A custom type or function that will be passed the direct response :return: Device, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.Device + :rtype: ~azure.mgmt.hybridnetwork.models.Device :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Device', pipeline_response) @@ -415,53 +709,61 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}'} # type: ignore + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}"} # type: ignore + + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DeviceListResult"] + **kwargs: Any + ) -> Iterable[_models.DeviceListResult]: """Lists all the devices in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.DeviceListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.DeviceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeviceListResult', pipeline_response) + deserialized = self._deserialize("DeviceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -470,70 +772,82 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/devices'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/devices"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DeviceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.DeviceListResult]: """Lists all the device resource in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.DeviceListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.DeviceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeviceListResult', pipeline_response) + deserialized = self._deserialize("DeviceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -542,28 +856,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices"} # type: ignore + @distributed_trace def list_registration_key( self, - resource_group_name, # type: str - device_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DeviceRegistrationKey" + resource_group_name: str, + device_name: str, + **kwargs: Any + ) -> _models.DeviceRegistrationKey: """List the registration key for the device. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -572,41 +891,43 @@ def list_registration_key( :type device_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DeviceRegistrationKey, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.DeviceRegistrationKey + :rtype: ~azure.mgmt.hybridnetwork.models.DeviceRegistrationKey :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceRegistrationKey"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.list_registration_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceRegistrationKey] + + + request = build_list_registration_key_request( + resource_group_name=resource_group_name, + device_name=device_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_registration_key.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeviceRegistrationKey', pipeline_response) @@ -615,4 +936,6 @@ def list_registration_key( return cls(pipeline_response, deserialized, {}) return deserialized - list_registration_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}/listRegistrationKey'} # type: ignore + + list_registration_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}/listRegistrationKey"} # type: ignore + diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendor_skus_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendor_skus_operations.py index cae7d17245ba..4be1dc00f4aa 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendor_skus_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendor_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,176 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_vendor_request( + vendor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_sku_request( + vendor_name: str, + vendor_sku_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus/{vendorSkuName}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "vendorSkuName": _SERIALIZER.url("vendor_sku_name", vendor_sku_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class NetworkFunctionVendorSkusOperations(object): - """NetworkFunctionVendorSkusOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NetworkFunctionVendorSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`network_function_vendor_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_vendor( self, - vendor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkFunctionSkuListResult"] + vendor_name: str, + **kwargs: Any + ) -> Iterable[_models.NetworkFunctionSkuListResult]: """Lists all network function vendor sku details in a vendor. :param vendor_name: The name of the network function vendor. :type vendor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionSkuListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.NetworkFunctionSkuListResult] + :return: An iterator like instance of either NetworkFunctionSkuListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_vendor.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_vendor_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_vendor.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_vendor_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionSkuListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,28 +184,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_vendor.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus'} # type: ignore + list_by_vendor.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus"} # type: ignore + @distributed_trace def list_by_sku( self, - vendor_name, # type: str - vendor_sku_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkFunctionSkuDetails"] + vendor_name: str, + vendor_sku_name: str, + **kwargs: Any + ) -> Iterable[_models.NetworkFunctionSkuDetails]: """Lists information about network function vendor sku details. :param vendor_name: The name of the network function vendor. @@ -131,45 +218,55 @@ def list_by_sku( :param vendor_sku_name: The name of the network function sku. :type vendor_sku_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionSkuDetails or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.NetworkFunctionSkuDetails] + :return: An iterator like instance of either NetworkFunctionSkuDetails or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionSkuDetails] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionSkuDetails"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionSkuDetails] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sku.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'vendorSkuName': self._serialize.url("vendor_sku_name", vendor_sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + vendor_name=vendor_name, + vendor_sku_name=vendor_sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_sku.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + vendor_name=vendor_name, + vendor_sku_name=vendor_sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionSkuDetails', pipeline_response) + deserialized = self._deserialize("NetworkFunctionSkuDetails", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,17 +275,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_sku.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus/{vendorSkuName}'} # type: ignore + list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors/{vendorName}/vendorSkus/{vendorSkuName}"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendors_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendors_operations.py index e23c0bcc8f71..b5704a0e248c 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendors_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_function_vendors_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class NetworkFunctionVendorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class NetworkFunctionVendorsOperations(object): - """NetworkFunctionVendorsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`network_function_vendors` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkFunctionVendorListResult"] + **kwargs: Any + ) -> Iterable[_models.NetworkFunctionVendorListResult]: """Lists all the available vendor and sku information. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionVendorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.NetworkFunctionVendorListResult] + :return: An iterator like instance of either NetworkFunctionVendorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionVendorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionVendorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionVendorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionVendorListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionVendorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,17 +140,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctionVendors"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_functions_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_functions_operations.py index 589ec4e9f65c..eb416753754c 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_functions_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_network_functions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,379 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request_initial( + resource_group_name: str, + network_function_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + network_function_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + network_function_name: str, + subscription_id: str, + *, + json: Optional[_models.NetworkFunction] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + network_function_name: str, + subscription_id: str, + *, + json: Optional[_models.TagsObject] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions") # 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), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_execute_request_request_initial( + resource_group_name: str, + network_function_name: str, + subscription_id: str, + *, + json: Optional[_models.ExecuteRequestParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/executeRequest") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class NetworkFunctionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class NetworkFunctionsOperations(object): - """NetworkFunctionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`network_functions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - network_function_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + network_function_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - network_function_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + network_function_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified network function resource. This operation can take up to 1 hour to complete. This is expected service behavior. @@ -109,44 +388,52 @@ def begin_delete( :type network_function_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, network_function_name=network_function_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -155,17 +442,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - network_function_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkFunction" + resource_group_name: str, + network_function_name: str, + **kwargs: Any + ) -> _models.NetworkFunction: """Gets information about the specified network function resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -174,41 +461,43 @@ def get( :type network_function_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkFunction, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.NetworkFunction + :rtype: ~azure.mgmt.hybridnetwork.models.NetworkFunction :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] + + + request = build_get_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkFunction', pipeline_response) @@ -217,54 +506,55 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - network_function_name, # type: str - parameters, # type: "_models.NetworkFunction" - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkFunction" - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] + resource_group_name: str, + network_function_name: str, + parameters: _models.NetworkFunction, + **kwargs: Any + ) -> _models.NetworkFunction: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkFunction') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] + + _json = self._serialize.body(parameters, 'NetworkFunction') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('NetworkFunction', pipeline_response) @@ -276,16 +566,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - network_function_name, # type: str - parameters, # type: "_models.NetworkFunction" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.NetworkFunction"] + resource_group_name: str, + network_function_name: str, + parameters: _models.NetworkFunction, + **kwargs: Any + ) -> LROPoller[_models.NetworkFunction]: """Creates or updates a network function resource. This operation can take up to 6 hours to complete. This is expected service behavior. @@ -295,51 +587,61 @@ def begin_create_or_update( :type network_function_name: str :param parameters: Parameters supplied in the body to the create or update network function operation. - :type parameters: ~hybrid_network_management_client.models.NetworkFunction + :type parameters: ~azure.mgmt.hybridnetwork.models.NetworkFunction :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. + :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 NetworkFunction or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~hybrid_network_management_client.models.NetworkFunction] - :raises ~azure.core.exceptions.HttpResponseError: + :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 NetworkFunction or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridnetwork.models.NetworkFunction] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, network_function_name=network_function_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('NetworkFunction', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -348,18 +650,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + @distributed_trace def update_tags( self, - resource_group_name, # type: str - network_function_name, # type: str - parameters, # type: "_models.TagsObject" - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkFunction" + resource_group_name: str, + network_function_name: str, + parameters: _models.TagsObject, + **kwargs: Any + ) -> _models.NetworkFunction: """Updates the tags for the network function resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -367,49 +669,50 @@ def update_tags( :param network_function_name: Resource name for the network function resource. :type network_function_name: str :param parameters: Parameters supplied to the update network function tags operation. - :type parameters: ~hybrid_network_management_client.models.TagsObject + :type parameters: ~azure.mgmt.hybridnetwork.models.TagsObject :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkFunction, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.NetworkFunction + :rtype: ~azure.mgmt.hybridnetwork.models.NetworkFunction :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunction"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'networkFunctionName': self._serialize.url("network_function_name", network_function_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunction] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkFunction', pipeline_response) @@ -418,53 +721,63 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}'} # type: ignore + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}"} # type: ignore + + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkFunctionListResult"] + **kwargs: Any + ) -> Iterable[_models.NetworkFunctionListResult]: """Lists all the network functions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.NetworkFunctionListResult] + :return: An iterator like instance of either NetworkFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -473,70 +786,84 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctions'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctions"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkFunctionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.NetworkFunctionListResult]: """Lists all the network function resources in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.NetworkFunctionListResult] + :return: An iterator like instance of either NetworkFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -545,17 +872,153 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions"} # type: ignore + + def _execute_request_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.ExecuteRequestParameters, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(parameters, 'ExecuteRequestParameters') + + request = build_execute_request_request_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._execute_request_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _execute_request_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/executeRequest"} # type: ignore + + + @distributed_trace + def begin_execute_request( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.ExecuteRequestParameters, + **kwargs: Any + ) -> LROPoller[None]: + """Execute a request to services on a network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param network_function_name: The name of the network function. + :type network_function_name: str + :param parameters: Payload for execute request post call. + :type parameters: ~azure.mgmt.hybridnetwork.models.ExecuteRequestParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._execute_request_initial( # type: ignore + resource_group_name=resource_group_name, + network_function_name=network_function_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_execute_request.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/executeRequest"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_operations.py index 47e44f3eb292..4a7a314af100 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +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 .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.HybridNetwork/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationList"] + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: """Gets a list of the operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.OperationList] + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +130,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.HybridNetwork/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.HybridNetwork/operations"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_patch.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_role_instances_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_role_instances_operations.py index 1d921a2f9a54..34b0938cf790 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_role_instances_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_role_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,311 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_start_request_initial( + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "serviceKey": _SERIALIZER.url("service_key", service_key, 'str'), + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_stop_request_initial( + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "serviceKey": _SERIALIZER.url("service_key", service_key, 'str'), + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_restart_request_initial( + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "serviceKey": _SERIALIZER.url("service_key", service_key, 'str'), + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "serviceKey": _SERIALIZER.url("service_key", service_key, 'str'), + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + location_name: str, + vendor_name: str, + service_key: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "serviceKey": _SERIALIZER.url("service_key", service_key, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class RoleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleInstancesOperations(object): - """RoleInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`role_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _start_initial( + def _start_initial( # pylint: disable=inconsistent-return-statements self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - role_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_start_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start'} # type: ignore + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start"} # type: ignore - def begin_start( + + @distributed_trace + def begin_start( # pylint: disable=inconsistent-return-statements self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - role_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Starts a role instance of a vendor network function. :param location_name: The Azure region where the network function resource was created by @@ -119,48 +324,54 @@ def begin_start( :type role_instance_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, role_instance_name=role_instance_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -169,69 +380,70 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/start"} # type: ignore - def _stop_initial( + def _stop_initial( # pylint: disable=inconsistent-return-statements self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - role_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_stop_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop'} # type: ignore + _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop"} # type: ignore + - def begin_stop( + @distributed_trace + def begin_stop( # pylint: disable=inconsistent-return-statements self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - role_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Powers off (stop) a role instance of a vendor network function. :param location_name: The Azure region where the network function resource was created by @@ -245,48 +457,54 @@ def begin_stop( :type role_instance_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, role_instance_name=role_instance_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -295,69 +513,70 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _restart_initial( + begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/stop"} # type: ignore + + def _restart_initial( # pylint: disable=inconsistent-return-statements self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - role_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._restart_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_restart_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart'} # type: ignore + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart"} # type: ignore + - def begin_restart( + @distributed_trace + def begin_restart( # pylint: disable=inconsistent-return-statements self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - role_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Restarts a role instance of a vendor network function. :param location_name: The Azure region where the network function resource was created by @@ -371,48 +590,54 @@ def begin_restart( :type role_instance_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._restart_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, role_instance_name=role_instance_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -421,19 +646,19 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}/restart"} # type: ignore + @distributed_trace def get( self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - role_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleInstance" + location_name: str, + vendor_name: str, + service_key: str, + role_instance_name: str, + **kwargs: Any + ) -> _models.RoleInstance: """Gets the information of role instance of vendor network function. :param location_name: The Azure region where the network function resource was created by @@ -447,43 +672,45 @@ def get( :type role_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleInstance, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.RoleInstance + :rtype: ~azure.mgmt.hybridnetwork.models.RoleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'roleInstanceName': self._serialize.url("role_instance_name", role_instance_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] + + + request = build_get_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + role_instance_name=role_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleInstance', pipeline_response) @@ -492,16 +719,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances/{roleInstanceName}"} # type: ignore + + + @distributed_trace def list( self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkFunctionRoleInstanceListResult"] + location_name: str, + vendor_name: str, + service_key: str, + **kwargs: Any + ) -> Iterable[_models.NetworkFunctionRoleInstanceListResult]: """Lists the information of role instances of vendor network function. :param location_name: The Azure region where the network function resource was created by @@ -512,46 +741,57 @@ def list( :param service_key: The GUID for the vendor network function. :type service_key: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkFunctionRoleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.NetworkFunctionRoleInstanceListResult] + :return: An iterator like instance of either NetworkFunctionRoleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.NetworkFunctionRoleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkFunctionRoleInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkFunctionRoleInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkFunctionRoleInstanceListResult', pipeline_response) + deserialized = self._deserialize("NetworkFunctionRoleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -560,17 +800,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}/roleInstances"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_network_functions_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_network_functions_operations.py index 710ce8885c7e..9aad0a8d096b 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_network_functions_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_network_functions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,56 +6,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + location_name: str, + vendor_name: str, + service_key: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "serviceKey": _SERIALIZER.url("service_key", service_key, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + location_name: str, + vendor_name: str, + service_key: str, + subscription_id: str, + *, + json: Optional[_models.VendorNetworkFunction] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "serviceKey": _SERIALIZER.url("service_key", service_key, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + location_name: str, + vendor_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions") # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class VendorNetworkFunctionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class VendorNetworkFunctionsOperations(object): - """VendorNetworkFunctionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`vendor_network_functions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get( self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VendorNetworkFunction" + location_name: str, + vendor_name: str, + service_key: str, + **kwargs: Any + ) -> _models.VendorNetworkFunction: """Gets information about the specified vendor network function. :param location_name: The Azure region where the network function resource was created by the @@ -66,42 +194,44 @@ def get( :type service_key: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VendorNetworkFunction, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.VendorNetworkFunction + :rtype: ~azure.mgmt.hybridnetwork.models.VendorNetworkFunction :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunction"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunction] + + + request = build_get_request( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VendorNetworkFunction', pipeline_response) @@ -110,56 +240,57 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}"} # type: ignore + def _create_or_update_initial( self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - parameters, # type: "_models.VendorNetworkFunction" - **kwargs # type: Any - ): - # type: (...) -> "_models.VendorNetworkFunction" - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunction"] + location_name: str, + vendor_name: str, + service_key: str, + parameters: _models.VendorNetworkFunction, + **kwargs: Any + ) -> _models.VendorNetworkFunction: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VendorNetworkFunction') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunction] + + _json = self._serialize.body(parameters, 'VendorNetworkFunction') + + request = build_create_or_update_request_initial( + location_name=location_name, + vendor_name=vendor_name, + service_key=service_key, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VendorNetworkFunction', pipeline_response) @@ -171,17 +302,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - location_name, # type: str - vendor_name, # type: str - service_key, # type: str - parameters, # type: "_models.VendorNetworkFunction" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VendorNetworkFunction"] + location_name: str, + vendor_name: str, + service_key: str, + parameters: _models.VendorNetworkFunction, + **kwargs: Any + ) -> LROPoller[_models.VendorNetworkFunction]: """Creates or updates a vendor network function. This operation can take up to 6 hours to complete. This is expected service behavior. @@ -194,53 +327,62 @@ def begin_create_or_update( :type service_key: str :param parameters: Parameters supplied to the create or update vendor network function operation. - :type parameters: ~hybrid_network_management_client.models.VendorNetworkFunction + :type parameters: ~azure.mgmt.hybridnetwork.models.VendorNetworkFunction :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. + :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 VendorNetworkFunction or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~hybrid_network_management_client.models.VendorNetworkFunction] - :raises ~azure.core.exceptions.HttpResponseError: + :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 VendorNetworkFunction or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridnetwork.models.VendorNetworkFunction] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunction] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunction"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore location_name=location_name, vendor_name=vendor_name, service_key=service_key, 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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('VendorNetworkFunction', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'serviceKey': self._serialize.url("service_key", service_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -249,18 +391,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}"} # type: ignore + + @distributed_trace def list( self, - location_name, # type: str - vendor_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VendorNetworkFunctionListResult"] + location_name: str, + vendor_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.VendorNetworkFunctionListResult]: """Lists all the vendor network function sub resources in an Azure region, filtered by skuType, skuName, vendorProvisioningState. @@ -270,50 +412,60 @@ def list( :param vendor_name: The name of the vendor. :type vendor_name: str :param filter: The filter to apply on the operation. The properties you can use for eq (equals) - are: skuType, skuName and vendorProvisioningState. + are: skuType, skuName and vendorProvisioningState. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VendorNetworkFunctionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.VendorNetworkFunctionListResult] + :return: An iterator like instance of either VendorNetworkFunctionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.VendorNetworkFunctionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorNetworkFunctionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorNetworkFunctionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + location_name=location_name, + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VendorNetworkFunctionListResult', pipeline_response) + deserialized = self._deserialize("VendorNetworkFunctionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -322,17 +474,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_sku_preview_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_sku_preview_operations.py index 546904e23491..b2c6a1482205 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_sku_preview_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_sku_preview_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,217 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + vendor_name: str, + sku_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + vendor_name: str, + sku_name: str, + preview_subscription: str, + subscription_id: str, + *, + json: Optional[_models.PreviewSubscription] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "previewSubscription": _SERIALIZER.url("preview_subscription", preview_subscription, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + vendor_name: str, + sku_name: str, + preview_subscription: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "previewSubscription": _SERIALIZER.url("preview_subscription", preview_subscription, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request_initial( + vendor_name: str, + sku_name: str, + preview_subscription: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "previewSubscription": _SERIALIZER.url("preview_subscription", preview_subscription, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class VendorSkuPreviewOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class VendorSkuPreviewOperations(object): - """VendorSkuPreviewOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`vendor_sku_preview` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - vendor_name, # type: str - sku_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PreviewSubscriptionsList"] + vendor_name: str, + sku_name: str, + **kwargs: Any + ) -> Iterable[_models.PreviewSubscriptionsList]: """Lists all the preview information of a vendor sku. :param vendor_name: The name of the vendor. @@ -61,45 +224,54 @@ def list( :param sku_name: The name of the sku. :type sku_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PreviewSubscriptionsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.PreviewSubscriptionsList] + :return: An iterator like instance of either PreviewSubscriptionsList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.PreviewSubscriptionsList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscriptionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscriptionsList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PreviewSubscriptionsList', pipeline_response) + deserialized = self._deserialize("PreviewSubscriptionsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,69 +280,73 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions"} # type: ignore def _create_or_update_initial( self, - vendor_name, # type: str - sku_name, # type: str - preview_subscription, # type: str - parameters, # type: "_models.PreviewSubscription" - **kwargs # type: Any - ): - # type: (...) -> "_models.PreviewSubscription" - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscription"] + vendor_name: str, + sku_name: str, + preview_subscription: str, + parameters: _models.PreviewSubscription, + **kwargs: Any + ) -> _models.PreviewSubscription: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PreviewSubscription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscription] + + _json = self._serialize.body(parameters, 'PreviewSubscription') + + request = build_create_or_update_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + preview_subscription=preview_subscription, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PreviewSubscription', pipeline_response) @@ -182,17 +358,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - vendor_name, # type: str - sku_name, # type: str - preview_subscription, # type: str - parameters, # type: "_models.PreviewSubscription" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PreviewSubscription"] + vendor_name: str, + sku_name: str, + preview_subscription: str, + parameters: _models.PreviewSubscription, + **kwargs: Any + ) -> LROPoller[_models.PreviewSubscription]: """Creates or updates preview information of a vendor sku. :param vendor_name: The name of the vendor. @@ -203,53 +381,62 @@ def begin_create_or_update( :type preview_subscription: str :param parameters: Parameters supplied to the create or update vendor preview subscription operation. - :type parameters: ~hybrid_network_management_client.models.PreviewSubscription + :type parameters: ~azure.mgmt.hybridnetwork.models.PreviewSubscription :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. + :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 PreviewSubscription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~hybrid_network_management_client.models.PreviewSubscription] - :raises ~azure.core.exceptions.HttpResponseError: + :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 PreviewSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridnetwork.models.PreviewSubscription] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscription] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscription"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_name, preview_subscription=preview_subscription, 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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('PreviewSubscription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -258,18 +445,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore + + @distributed_trace def get( self, - vendor_name, # type: str - sku_name, # type: str - preview_subscription, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PreviewSubscription" + vendor_name: str, + sku_name: str, + preview_subscription: str, + **kwargs: Any + ) -> _models.PreviewSubscription: """Gets the preview information of a vendor sku. :param vendor_name: The name of the vendor. @@ -280,42 +467,44 @@ def get( :type preview_subscription: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PreviewSubscription, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.PreviewSubscription + :rtype: ~azure.mgmt.hybridnetwork.models.PreviewSubscription :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PreviewSubscription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PreviewSubscription] + + + request = build_get_request( + vendor_name=vendor_name, + sku_name=sku_name, + preview_subscription=preview_subscription, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PreviewSubscription', pipeline_response) @@ -324,64 +513,67 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore - def _delete_initial( + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - vendor_name, # type: str - sku_name, # type: str - preview_subscription, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + vendor_name: str, + sku_name: str, + preview_subscription: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + preview_subscription=preview_subscription, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - vendor_name, # type: str - sku_name, # type: str - preview_subscription, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + vendor_name: str, + sku_name: str, + preview_subscription: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the preview information of a vendor sku. :param vendor_name: The name of the vendor. @@ -392,46 +584,53 @@ def begin_delete( :type preview_subscription: 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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_name, preview_subscription=preview_subscription, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'previewSubscription': self._serialize.url("preview_subscription", preview_subscription, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -440,6 +639,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}"} # type: ignore diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_skus_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_skus_operations.py index d10c5b7442b7..3892afadda4d 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_skus_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendor_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,293 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request_initial( + vendor_name: str, + sku_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + vendor_name: str, + sku_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + vendor_name: str, + sku_name: str, + subscription_id: str, + *, + json: Optional[_models.VendorSku] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + vendor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_credential_request( + vendor_name: str, + sku_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/listCredential") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "skuName": _SERIALIZER.url("sku_name", sku_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class VendorSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class VendorSkusOperations(object): - """VendorSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`vendor_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - vendor_name, # type: str - sku_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + vendor_name: str, + sku_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - vendor_name, # type: str - sku_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + vendor_name: str, + sku_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified sku. This operation can take up to 2 hours to complete. This is expected service behavior. @@ -109,44 +302,52 @@ def begin_delete( :type sku_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -155,17 +356,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + @distributed_trace def get( self, - vendor_name, # type: str - sku_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VendorSku" + vendor_name: str, + sku_name: str, + **kwargs: Any + ) -> _models.VendorSku: """Gets information about the specified sku. :param vendor_name: The name of the vendor. @@ -174,41 +375,43 @@ def get( :type sku_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VendorSku, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.VendorSku + :rtype: ~azure.mgmt.hybridnetwork.models.VendorSku :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSku"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSku] + + + request = build_get_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VendorSku', pipeline_response) @@ -217,54 +420,55 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + def _create_or_update_initial( self, - vendor_name, # type: str - sku_name, # type: str - parameters, # type: "_models.VendorSku" - **kwargs # type: Any - ): - # type: (...) -> "_models.VendorSku" - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSku"] + vendor_name: str, + sku_name: str, + parameters: _models.VendorSku, + **kwargs: Any + ) -> _models.VendorSku: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VendorSku') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSku] + + _json = self._serialize.body(parameters, 'VendorSku') + + request = build_create_or_update_request_initial( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VendorSku', pipeline_response) @@ -276,16 +480,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - vendor_name, # type: str - sku_name, # type: str - parameters, # type: "_models.VendorSku" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VendorSku"] + vendor_name: str, + sku_name: str, + parameters: _models.VendorSku, + **kwargs: Any + ) -> LROPoller[_models.VendorSku]: """Creates or updates a sku. This operation can take up to 2 hours to complete. This is expected service behavior. @@ -294,51 +500,60 @@ def begin_create_or_update( :param sku_name: The name of the sku. :type sku_name: str :param parameters: Parameters supplied to the create or update sku operation. - :type parameters: ~hybrid_network_management_client.models.VendorSku + :type parameters: ~azure.mgmt.hybridnetwork.models.VendorSku :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. + :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. + :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 VendorSku or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~hybrid_network_management_client.models.VendorSku] - :raises ~azure.core.exceptions.HttpResponseError: + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridnetwork.models.VendorSku] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSku] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSku"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore vendor_name=vendor_name, sku_name=sku_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('VendorSku', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'skuName': self._serialize.url("sku_name", sku_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -347,59 +562,66 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}"} # type: ignore + @distributed_trace def list( self, - vendor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VendorSkuListResult"] + vendor_name: str, + **kwargs: Any + ) -> Iterable[_models.VendorSkuListResult]: """Lists all the skus of a vendor. :param vendor_name: The name of the vendor. :type vendor_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VendorSkuListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.VendorSkuListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.VendorSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VendorSkuListResult', pipeline_response) + deserialized = self._deserialize("VendorSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -408,17 +630,86 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus"} # type: ignore + + @distributed_trace + def list_credential( + self, + vendor_name: str, + sku_name: str, + **kwargs: Any + ) -> _models.SkuCredential: + """Generate credentials for publishing SKU images. + + :param vendor_name: The name of the vendor. + :type vendor_name: str + :param sku_name: The name of the sku. + :type sku_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SkuCredential, or the result of cls(response) + :rtype: ~azure.mgmt.hybridnetwork.models.SkuCredential + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SkuCredential] + + + request = build_list_credential_request( + vendor_name=vendor_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credential.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SkuCredential', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credential.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/listCredential"} # type: ignore + diff --git a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendors_operations.py b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendors_operations.py index 5239ca3453f1..e3a83e7423aa 100644 --- a/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendors_operations.py +++ b/sdk/hybridnetwork/azure-mgmt-hybridnetwork/azure/mgmt/hybridnetwork/operations/_vendors_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,140 +6,296 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request_initial( + vendor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + vendor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + vendor_name: str, + subscription_id: str, + *, + json: Optional[_models.Vendor] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}") # pylint: disable=line-too-long + path_format_arguments = { + "vendorName": _SERIALIZER.url("vendor_name", vendor_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class VendorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class VendorsOperations(object): - """VendorsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~hybrid_network_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridnetwork.HybridNetworkManagementClient`'s + :attr:`vendors` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - vendor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + vendor_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request_initial( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - vendor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + vendor_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified vendor. :param vendor_name: The name of the vendor. :type vendor_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. + :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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore vendor_name=vendor_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -147,56 +304,58 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + @distributed_trace def get( self, - vendor_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Vendor" + vendor_name: str, + **kwargs: Any + ) -> _models.Vendor: """Gets information about the specified vendor. :param vendor_name: The name of the vendor. :type vendor_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Vendor, or the result of cls(response) - :rtype: ~hybrid_network_management_client.models.Vendor + :rtype: ~azure.mgmt.hybridnetwork.models.Vendor :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Vendor"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Vendor] + + + request = build_get_request( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Vendor', pipeline_response) @@ -205,55 +364,56 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + def _create_or_update_initial( self, - vendor_name, # type: str - parameters=None, # type: Optional["_models.Vendor"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Vendor" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Vendor"] + vendor_name: str, + parameters: Optional[_models.Vendor] = None, + **kwargs: Any + ) -> _models.Vendor: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Vendor] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'Vendor') + _json = self._serialize.body(parameters, 'Vendor') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_create_or_update_request_initial( + vendor_name=vendor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Vendor', pipeline_response) @@ -265,63 +425,75 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - vendor_name, # type: str - parameters=None, # type: Optional["_models.Vendor"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Vendor"] + vendor_name: str, + parameters: Optional[_models.Vendor] = None, + **kwargs: Any + ) -> LROPoller[_models.Vendor]: """Creates or updates a vendor. :param vendor_name: The name of the vendor. :type vendor_name: str - :param parameters: Parameters supplied to the create vendor operation. - :type parameters: ~hybrid_network_management_client.models.Vendor + :param parameters: Parameters supplied to the create vendor operation. Default value is None. + :type parameters: ~azure.mgmt.hybridnetwork.models.Vendor :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. + :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. + :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 Vendor or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~hybrid_network_management_client.models.Vendor] - :raises ~azure.core.exceptions.HttpResponseError: + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridnetwork.models.Vendor] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Vendor] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Vendor"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore vendor_name=vendor_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) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Vendor', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vendorName': self._serialize.url("vendor_name", vendor_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -330,55 +502,61 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}"} # type: ignore + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VendorListResult"] + **kwargs: Any + ) -> Iterable[_models.VendorListResult]: """Lists all the vendors in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VendorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~hybrid_network_management_client.models.VendorListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridnetwork.models.VendorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VendorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VendorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VendorListResult', pipeline_response) + deserialized = self._deserialize("VendorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -387,17 +565,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors"} # type: ignore