From 89df2346dd3f14cc02c47b98be450abb71490afd Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 20 Apr 2022 08:31:31 +0000 Subject: [PATCH] CodeGen from PR 18747 in Azure/azure-rest-api-specs Update readme.python.md (#18747) --- sdk/scvmm/azure-mgmt-scvmm/CHANGELOG.md | 5 + sdk/scvmm/azure-mgmt-scvmm/LICENSE | 21 + sdk/scvmm/azure-mgmt-scvmm/MANIFEST.in | 6 + sdk/scvmm/azure-mgmt-scvmm/README.md | 30 + sdk/scvmm/azure-mgmt-scvmm/_meta.json | 11 + sdk/scvmm/azure-mgmt-scvmm/azure/__init__.py | 1 + .../azure-mgmt-scvmm/azure/mgmt/__init__.py | 1 + .../azure/mgmt/scvmm/__init__.py | 18 + .../azure/mgmt/scvmm/_configuration.py | 74 + .../azure/mgmt/scvmm/_metadata.json | 109 + .../azure/mgmt/scvmm/_patch.py | 31 + .../azure/mgmt/scvmm/_scvmm.py | 120 + .../azure/mgmt/scvmm/_vendor.py | 27 + .../azure/mgmt/scvmm/_version.py | 9 + .../azure/mgmt/scvmm/aio/__init__.py | 15 + .../azure/mgmt/scvmm/aio/_configuration.py | 73 + .../azure/mgmt/scvmm/aio/_patch.py | 31 + .../azure/mgmt/scvmm/aio/_scvmm.py | 117 + .../mgmt/scvmm/aio/operations/__init__.py | 27 + .../_availability_sets_operations.py | 646 ++++ .../aio/operations/_clouds_operations.py | 632 ++++ .../operations/_inventory_items_operations.py | 331 ++ .../mgmt/scvmm/aio/operations/_operations.py | 117 + .../_virtual_machine_templates_operations.py | 638 ++++ .../_virtual_machines_operations.py | 1337 ++++++++ .../_virtual_networks_operations.py | 638 ++++ .../aio/operations/_vmm_servers_operations.py | 634 ++++ .../azure/mgmt/scvmm/models/__init__.py | 137 + .../azure/mgmt/scvmm/models/_models_py3.py | 2875 +++++++++++++++++ .../azure/mgmt/scvmm/models/_scvmm_enums.py | 74 + .../azure/mgmt/scvmm/operations/__init__.py | 27 + .../_availability_sets_operations.py | 877 +++++ .../scvmm/operations/_clouds_operations.py | 865 +++++ .../operations/_inventory_items_operations.py | 492 +++ .../mgmt/scvmm/operations/_operations.py | 145 + .../_virtual_machine_templates_operations.py | 869 +++++ .../_virtual_machines_operations.py | 1819 +++++++++++ .../_virtual_networks_operations.py | 869 +++++ .../operations/_vmm_servers_operations.py | 865 +++++ .../azure/mgmt/scvmm/py.typed | 1 + sdk/scvmm/azure-mgmt-scvmm/sdk_packaging.toml | 9 + sdk/scvmm/azure-mgmt-scvmm/setup.py | 74 + sdk/scvmm/ci.yml | 33 + 43 files changed, 15730 insertions(+) create mode 100644 sdk/scvmm/azure-mgmt-scvmm/CHANGELOG.md create mode 100644 sdk/scvmm/azure-mgmt-scvmm/LICENSE create mode 100644 sdk/scvmm/azure-mgmt-scvmm/MANIFEST.in create mode 100644 sdk/scvmm/azure-mgmt-scvmm/README.md create mode 100644 sdk/scvmm/azure-mgmt-scvmm/_meta.json create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/__init__.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/__init__.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/__init__.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_configuration.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_metadata.json create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_patch.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_scvmm.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_vendor.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_version.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/__init__.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_configuration.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_patch.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_scvmm.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/__init__.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_availability_sets_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_clouds_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_inventory_items_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machine_templates_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machines_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_networks_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_vmm_servers_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/__init__.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_models_py3.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_scvmm_enums.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/__init__.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_availability_sets_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_clouds_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_inventory_items_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machine_templates_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machines_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_networks_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_vmm_servers_operations.py create mode 100644 sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/py.typed create mode 100644 sdk/scvmm/azure-mgmt-scvmm/sdk_packaging.toml create mode 100644 sdk/scvmm/azure-mgmt-scvmm/setup.py create mode 100644 sdk/scvmm/ci.yml diff --git a/sdk/scvmm/azure-mgmt-scvmm/CHANGELOG.md b/sdk/scvmm/azure-mgmt-scvmm/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/scvmm/azure-mgmt-scvmm/LICENSE b/sdk/scvmm/azure-mgmt-scvmm/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/scvmm/azure-mgmt-scvmm/MANIFEST.in b/sdk/scvmm/azure-mgmt-scvmm/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE diff --git a/sdk/scvmm/azure-mgmt-scvmm/README.md b/sdk/scvmm/azure-mgmt-scvmm/README.md new file mode 100644 index 000000000000..d25c95b2779c --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-scvmm%2FREADME.png) diff --git a/sdk/scvmm/azure-mgmt-scvmm/_meta.json b/sdk/scvmm/azure-mgmt-scvmm/_meta.json new file mode 100644 index 000000000000..2deeb92d059a --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "2d58f12d3885fe2e88d0bf5c7c6386b919ed85bb", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/scvmm/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/scvmm/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/__init__.py b/sdk/scvmm/azure-mgmt-scvmm/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/__init__.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/__init__.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/__init__.py new file mode 100644 index 000000000000..f89f33d8e7c4 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._scvmm import SCVMM +from ._version import VERSION + +__version__ = VERSION +__all__ = ['SCVMM'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_configuration.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_configuration.py new file mode 100644 index 000000000000..b02dd7196fc0 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_configuration.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SCVMMConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SCVMM. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-06-05-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(SCVMMConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-06-05-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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-scvmm/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_metadata.json b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_metadata.json new file mode 100644 index 000000000000..e5bcd3b46207 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_metadata.json @@ -0,0 +1,109 @@ +{ + "chosen_version": "2020-06-05-preview", + "total_api_version_list": ["2020-06-05-preview"], + "client": { + "name": "SCVMM", + "filename": "_scvmm", + "description": "The Microsoft.ScVmm Rest API spec.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SCVMMConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SCVMMConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "vmm_servers": "VmmServersOperations", + "operations": "Operations", + "clouds": "CloudsOperations", + "virtual_networks": "VirtualNetworksOperations", + "virtual_machines": "VirtualMachinesOperations", + "virtual_machine_templates": "VirtualMachineTemplatesOperations", + "availability_sets": "AvailabilitySetsOperations", + "inventory_items": "InventoryItemsOperations" + } +} \ No newline at end of file diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_patch.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_scvmm.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_scvmm.py new file mode 100644 index 000000000000..cc9cef4607a4 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_scvmm.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import SCVMMConfiguration +from .operations import AvailabilitySetsOperations, CloudsOperations, InventoryItemsOperations, Operations, VirtualMachineTemplatesOperations, VirtualMachinesOperations, VirtualNetworksOperations, VmmServersOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class SCVMM: # pylint: disable=too-many-instance-attributes + """The Microsoft.ScVmm Rest API spec. + + :ivar vmm_servers: VmmServersOperations operations + :vartype vmm_servers: azure.mgmt.scvmm.operations.VmmServersOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.scvmm.operations.Operations + :ivar clouds: CloudsOperations operations + :vartype clouds: azure.mgmt.scvmm.operations.CloudsOperations + :ivar virtual_networks: VirtualNetworksOperations operations + :vartype virtual_networks: azure.mgmt.scvmm.operations.VirtualNetworksOperations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.scvmm.operations.VirtualMachinesOperations + :ivar virtual_machine_templates: VirtualMachineTemplatesOperations operations + :vartype virtual_machine_templates: + azure.mgmt.scvmm.operations.VirtualMachineTemplatesOperations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: azure.mgmt.scvmm.operations.AvailabilitySetsOperations + :ivar inventory_items: InventoryItemsOperations operations + :vartype inventory_items: azure.mgmt.scvmm.operations.InventoryItemsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-06-05-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: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SCVMMConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.vmm_servers = VmmServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.clouds = CloudsOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_networks = VirtualNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_templates = VirtualMachineTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.inventory_items = InventoryItemsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SCVMM + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_vendor.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_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/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_version.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/__init__.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/__init__.py new file mode 100644 index 000000000000..999c43018565 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._scvmm import SCVMM +__all__ = ['SCVMM'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_configuration.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_configuration.py new file mode 100644 index 000000000000..8c2f2757aae9 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SCVMMConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SCVMM. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-06-05-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(SCVMMConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-06-05-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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-scvmm/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_patch.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_scvmm.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_scvmm.py new file mode 100644 index 000000000000..1d467ccbda4e --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/_scvmm.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import SCVMMConfiguration +from .operations import AvailabilitySetsOperations, CloudsOperations, InventoryItemsOperations, Operations, VirtualMachineTemplatesOperations, VirtualMachinesOperations, VirtualNetworksOperations, VmmServersOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class SCVMM: # pylint: disable=too-many-instance-attributes + """The Microsoft.ScVmm Rest API spec. + + :ivar vmm_servers: VmmServersOperations operations + :vartype vmm_servers: azure.mgmt.scvmm.aio.operations.VmmServersOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.scvmm.aio.operations.Operations + :ivar clouds: CloudsOperations operations + :vartype clouds: azure.mgmt.scvmm.aio.operations.CloudsOperations + :ivar virtual_networks: VirtualNetworksOperations operations + :vartype virtual_networks: azure.mgmt.scvmm.aio.operations.VirtualNetworksOperations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.scvmm.aio.operations.VirtualMachinesOperations + :ivar virtual_machine_templates: VirtualMachineTemplatesOperations operations + :vartype virtual_machine_templates: + azure.mgmt.scvmm.aio.operations.VirtualMachineTemplatesOperations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: azure.mgmt.scvmm.aio.operations.AvailabilitySetsOperations + :ivar inventory_items: InventoryItemsOperations operations + :vartype inventory_items: azure.mgmt.scvmm.aio.operations.InventoryItemsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-06-05-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: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SCVMMConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.vmm_servers = VmmServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.clouds = CloudsOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_networks = VirtualNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_templates = VirtualMachineTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.inventory_items = InventoryItemsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SCVMM": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/__init__.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/__init__.py new file mode 100644 index 000000000000..f3a65f5c15f0 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/__init__.py @@ -0,0 +1,27 @@ +# 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 ._vmm_servers_operations import VmmServersOperations +from ._operations import Operations +from ._clouds_operations import CloudsOperations +from ._virtual_networks_operations import VirtualNetworksOperations +from ._virtual_machines_operations import VirtualMachinesOperations +from ._virtual_machine_templates_operations import VirtualMachineTemplatesOperations +from ._availability_sets_operations import AvailabilitySetsOperations +from ._inventory_items_operations import InventoryItemsOperations + +__all__ = [ + 'VmmServersOperations', + 'Operations', + 'CloudsOperations', + 'VirtualNetworksOperations', + 'VirtualMachinesOperations', + 'VirtualMachineTemplatesOperations', + 'AvailabilitySetsOperations', + 'InventoryItemsOperations', +] diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_availability_sets_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_availability_sets_operations.py new file mode 100644 index 000000000000..3f071d3b9027 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_availability_sets_operations.py @@ -0,0 +1,646 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._availability_sets_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AvailabilitySetsOperations: + """AvailabilitySetsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + availability_set_name: str, + **kwargs: Any + ) -> "_models.AvailabilitySet": + """Gets an AvailabilitySet. + + Implements AvailabilitySet GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilitySet, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.AvailabilitySet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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('AvailabilitySet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.AvailabilitySet", + **kwargs: Any + ) -> "_models.AvailabilitySet": + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'AvailabilitySet') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if response.status_code == 201: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.AvailabilitySet", + **kwargs: Any + ) -> AsyncLROPoller["_models.AvailabilitySet"]: + """Implements AvailabilitySets PUT method. + + Onboards the ScVmm availability set as an Azure resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.AvailabilitySet + :keyword callable cls: A custom type 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 AvailabilitySet or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.AvailabilitySet] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + availability_set_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + availability_set_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements AvailabilitySet DELETE method. + + Deregisters the ScVmm availability set from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.AvailabilitySet"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AvailabilitySet"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + availability_set_name=availability_set_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> AsyncLROPoller["_models.AvailabilitySet"]: + """Implements the AvailabilitySets PATCH method. + + Updates the AvailabilitySets resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :param body: AvailabilitySets patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 AvailabilitySet or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.AvailabilitySet] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + 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._update_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + """Implements GET AvailabilitySets in a resource group. + + List of AvailabilitySets in a resource group. + + :param resource_group_name: The name of the resource group. + :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 AvailabilitySetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.AvailabilitySetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + """Implements GET AvailabilitySets in a subscription. + + List of AvailabilitySets 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 AvailabilitySetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.AvailabilitySetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/availabilitySets"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_clouds_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_clouds_operations.py new file mode 100644 index 000000000000..0b632ba16457 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_clouds_operations.py @@ -0,0 +1,632 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._clouds_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CloudsOperations: + """CloudsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cloud_name: str, + **kwargs: Any + ) -> "_models.Cloud": + """Gets a Cloud. + + Implements Cloud GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cloud, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.Cloud + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cloud_name=cloud_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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('Cloud', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.Cloud", + **kwargs: Any + ) -> "_models.Cloud": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'Cloud') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cloud_name=cloud_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Cloud', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Cloud', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.Cloud", + **kwargs: Any + ) -> AsyncLROPoller["_models.Cloud"]: + """Implements Clouds PUT method. + + Onboards the ScVmm fabric cloud as an Azure cloud resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.Cloud + :keyword callable cls: A custom type 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 Cloud or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.Cloud] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + cloud_name=cloud_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Cloud', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cloud_name=cloud_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements Cloud resource DELETE method. + + Deregisters the ScVmm fabric cloud from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cloud_name=cloud_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.Cloud"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Cloud"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cloud_name=cloud_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Cloud', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Cloud', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> AsyncLROPoller["_models.Cloud"]: + """Implements the Clouds PATCH method. + + Updates the Clouds resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :param body: Clouds patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 Cloud or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.Cloud] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + 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._update_initial( + resource_group_name=resource_group_name, + cloud_name=cloud_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Cloud', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.CloudListResult"]: + """Implements GET Clouds in a resource group. + + List of Clouds in a resource group. + + :param resource_group_name: The name of the resource group. + :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 CloudListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.CloudListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CloudListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.CloudListResult"]: + """Implements GET Clouds in a subscription. + + List of Clouds 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 CloudListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.CloudListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CloudListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/clouds"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_inventory_items_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_inventory_items_operations.py new file mode 100644 index 000000000000..60b414f09ecc --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_inventory_items_operations.py @@ -0,0 +1,331 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._inventory_items_operations import build_create_request, build_delete_request, build_get_request, build_list_by_vmm_server_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class InventoryItemsOperations: + """InventoryItemsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + body: Optional["_models.InventoryItem"] = None, + **kwargs: Any + ) -> "_models.InventoryItem": + """Implements InventoryItem PUT method. + + Create Or Update InventoryItem. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.InventoryItem + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.InventoryItem + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'InventoryItem') + else: + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('InventoryItem', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> "_models.InventoryItem": + """Implements GET InventoryItem method. + + Shows an inventory item. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.InventoryItem + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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('InventoryItem', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> None: + """Implements inventoryItem DELETE method. + + Deletes an inventoryItem. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace + def list_by_vmm_server( + self, + resource_group_name: str, + vmm_server_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.InventoryItemsList"]: + """Implements GET for the list of Inventory Items in the VMMServer. + + Returns the list of inventoryItems in the given VMMServer. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InventoryItemsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.InventoryItemsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItemsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_vmm_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + template_url=self.list_by_vmm_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_vmm_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("InventoryItemsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_vmm_server.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_operations.py new file mode 100644 index 000000000000..2a05611d80c9 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_operations.py @@ -0,0 +1,117 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ResourceProviderOperationList"]: + """Returns list of all operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ScVmm/operations"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machine_templates_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machine_templates_operations.py new file mode 100644 index 000000000000..f9d4e76e1e8a --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machine_templates_operations.py @@ -0,0 +1,638 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_machine_templates_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualMachineTemplatesOperations: + """VirtualMachineTemplatesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_machine_template_name: str, + **kwargs: Any + ) -> "_models.VirtualMachineTemplate": + """Gets a VirtualMachineTemplate. + + Implements VirtualMachineTemplate GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VirtualMachineTemplate + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.VirtualMachineTemplate", + **kwargs: Any + ) -> "_models.VirtualMachineTemplate": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualMachineTemplate') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.VirtualMachineTemplate", + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualMachineTemplate"]: + """Implements VirtualMachineTemplates PUT method. + + Onboards the ScVmm VM Template as an Azure VM Template resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineTemplate + :keyword callable cls: A custom type 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 VirtualMachineTemplate or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VirtualMachineTemplate] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements VirtualMachineTemplate DELETE method. + + Deregisters the ScVmm VM Template from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.VirtualMachineTemplate"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineTemplate"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualMachineTemplate"]: + """Implements the VirtualMachineTemplate PATCH method. + + Updates the VirtualMachineTemplate resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :param body: VirtualMachineTemplates patch details. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 VirtualMachineTemplate or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VirtualMachineTemplate] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + 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._update_initial( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineTemplateListResult"]: + """Implements GET VirtualMachineTemplates in a resource group. + + List of VirtualMachineTemplates in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VirtualMachineTemplateListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VirtualMachineTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineTemplateListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineTemplateListResult"]: + """Implements GET VirtualMachineTemplates in a subscription. + + List of VirtualMachineTemplates 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 VirtualMachineTemplateListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VirtualMachineTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineTemplateListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachineTemplates"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machines_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machines_operations.py new file mode 100644 index 000000000000..c7e6df021c75 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_machines_operations.py @@ -0,0 +1,1337 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_machines_operations import build_create_checkpoint_request_initial, build_create_or_update_request_initial, build_delete_checkpoint_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_restart_request_initial, build_restore_checkpoint_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualMachinesOperations: # pylint: disable=too-many-public-methods + """VirtualMachinesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> "_models.VirtualMachine": + """Gets a VirtualMachine. + + Implements VirtualMachine GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachine", + **kwargs: Any + ) -> "_models.VirtualMachine": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualMachine') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachine", + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualMachine"]: + """Implements VirtualMachines PUT method. + + Creates Or Updates virtual machines deployed on scvmm fabric. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VirtualMachine + :keyword callable cls: A custom type 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 VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VirtualMachine] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachine', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + retain: Optional[bool] = None, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + retain=retain, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + retain: Optional[bool] = None, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements VirtualMachine DELETE method. + + Deletes a VirtualMachine deployed on ScVmm fabric. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param retain: Whether to just disable the VM from azure and retain the VM in the VMM. Default + value is None. + :type retain: bool + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + retain=retain, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachineUpdate", + **kwargs: Any + ) -> Optional["_models.VirtualMachine"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachine"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualMachineUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachineUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualMachine"]: + """Implements the VirtualMachines PATCH method. + + Updates the VirtualMachines resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: VirtualMachines patch payload. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineUpdate + :keyword callable cls: A custom type 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 VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VirtualMachine] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + 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._update_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachine', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + async def _stop_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.StopVirtualMachineOptions"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'StopVirtualMachineOptions') + else: + _json = None + + request = build_stop_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/stop"} # type: ignore + + + @distributed_trace_async + async def begin_stop( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.StopVirtualMachineOptions"] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to stop a virtual machine. + + Stop virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine stop action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.StopVirtualMachineOptions + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._stop_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/stop"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_start_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/start"} # type: ignore + + + @distributed_trace_async + async def begin_start( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to start a virtual machine. + + Start virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/start"} # type: ignore + + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_restart_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + + @distributed_trace_async + async def begin_restart( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to restart a virtual machine. + + Restart virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._restart_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + async def _create_checkpoint_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineCreateCheckpoint"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineCreateCheckpoint') + else: + _json = None + + request = build_create_checkpoint_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_checkpoint_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _create_checkpoint_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/createCheckpoint"} # type: ignore + + + @distributed_trace_async + async def begin_create_checkpoint( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineCreateCheckpoint"] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to creates a checkpoint in a virtual machine. + + Creates a checkpoint in virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine create checkpoint action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineCreateCheckpoint + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_checkpoint_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_checkpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/createCheckpoint"} # type: ignore + + async def _delete_checkpoint_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineDeleteCheckpoint"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineDeleteCheckpoint') + else: + _json = None + + request = build_delete_checkpoint_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._delete_checkpoint_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _delete_checkpoint_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/deleteCheckpoint"} # type: ignore + + + @distributed_trace_async + async def begin_delete_checkpoint( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineDeleteCheckpoint"] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to delete a checkpoint in a virtual machine. + + Deletes a checkpoint in virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine delete checkpoint action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineDeleteCheckpoint + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_checkpoint_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_checkpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/deleteCheckpoint"} # type: ignore + + async def _restore_checkpoint_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineRestoreCheckpoint"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineRestoreCheckpoint') + else: + _json = None + + request = build_restore_checkpoint_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._restore_checkpoint_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _restore_checkpoint_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restoreCheckpoint"} # type: ignore + + + @distributed_trace_async + async def begin_restore_checkpoint( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineRestoreCheckpoint"] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to restores to a checkpoint in a virtual machine. + + Restores to a checkpoint in virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine restore checkpoint action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineRestoreCheckpoint + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._restore_checkpoint_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restore_checkpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restoreCheckpoint"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineListResult"]: + """Implements GET VirtualMachines in a resource group. + + List of VirtualMachines in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VirtualMachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineListResult"]: + """Implements GET VirtualMachines in a subscription. + + List of VirtualMachines 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 VirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VirtualMachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachines"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_networks_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_networks_operations.py new file mode 100644 index 000000000000..31b05a05e31f --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_virtual_networks_operations.py @@ -0,0 +1,638 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_networks_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualNetworksOperations: + """VirtualNetworksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_network_name: str, + **kwargs: Any + ) -> "_models.VirtualNetwork": + """Gets a VirtualNetwork. + + Implements VirtualNetwork GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VirtualNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.VirtualNetwork", + **kwargs: Any + ) -> "_models.VirtualNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.VirtualNetwork", + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualNetwork"]: + """Implements VirtualNetworks PUT method. + + Onboards the ScVmm virtual network as an Azure virtual network resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VirtualNetwork + :keyword callable cls: A custom type 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 VirtualNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VirtualNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements VirtualNetwork DELETE method. + + Deregisters the ScVmm virtual network from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.VirtualNetwork"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetwork"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_network_name=virtual_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualNetwork"]: + """Implements the VirtualNetworks PATCH method. + + Updates the VirtualNetworks resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :param body: VirtualNetworks patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 VirtualNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VirtualNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + 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._update_initial( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetworkListResult"]: + """Implements GET VirtualNetworks in a resource group. + + List of VirtualNetworks in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VirtualNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VirtualNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetworkListResult"]: + """Implements GET VirtualNetworks in a subscription. + + List of VirtualNetworks 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 VirtualNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VirtualNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualNetworks"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_vmm_servers_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_vmm_servers_operations.py new file mode 100644 index 000000000000..9dcfd3c2435c --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/aio/operations/_vmm_servers_operations.py @@ -0,0 +1,634 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._vmm_servers_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VmmServersOperations: + """VmmServersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vmm_server_name: str, + **kwargs: Any + ) -> "_models.VMMServer": + """Gets a VMMServer. + + Implements VMMServer GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VMMServer, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VMMServer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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('VMMServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.VMMServer", + **kwargs: Any + ) -> "_models.VMMServer": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VMMServer') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.VMMServer", + **kwargs: Any + ) -> AsyncLROPoller["_models.VMMServer"]: + """Implements VmmServers PUT method. + + Onboards the SCVMM fabric as an Azure VmmServer resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VMMServer + :keyword callable cls: A custom type 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 VMMServer or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VMMServer] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VMMServer', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vmm_server_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vmm_server_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements VmmServers DELETE method. + + Deboards the SCVMM fabric from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.VMMServer"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VMMServer"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vmm_server_name=vmm_server_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> AsyncLROPoller["_models.VMMServer"]: + """Implements VmmServers PATCH method. + + Updates the VmmServers resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param body: VmmServers patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 VMMServer or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.scvmm.models.VMMServer] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + 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._update_initial( + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VMMServer', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VMMServerListResult"]: + """Implements GET VmmServers in a resource group. + + List of VmmServers in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VMMServerListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VMMServerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VMMServerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.VMMServerListResult"]: + """Implements GET VmmServers in a subscription. + + List of VmmServers 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 VMMServerListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.scvmm.models.VMMServerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VMMServerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/vmmServers"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/__init__.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/__init__.py new file mode 100644 index 000000000000..aef2859799a5 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/__init__.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AvailabilitySet +from ._models_py3 import AvailabilitySetListItem +from ._models_py3 import AvailabilitySetListResult +from ._models_py3 import Checkpoint +from ._models_py3 import Cloud +from ._models_py3 import CloudCapacity +from ._models_py3 import CloudInventoryItem +from ._models_py3 import CloudListResult +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorResponse +from ._models_py3 import ExtendedLocation +from ._models_py3 import HardwareProfile +from ._models_py3 import HardwareProfileUpdate +from ._models_py3 import InventoryItem +from ._models_py3 import InventoryItemDetails +from ._models_py3 import InventoryItemProperties +from ._models_py3 import InventoryItemsList +from ._models_py3 import NetworkInterfaces +from ._models_py3 import NetworkInterfacesUpdate +from ._models_py3 import NetworkProfile +from ._models_py3 import NetworkProfileUpdate +from ._models_py3 import OsProfile +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ResourcePatch +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import StopVirtualMachineOptions +from ._models_py3 import StorageProfile +from ._models_py3 import StorageProfileUpdate +from ._models_py3 import StorageQoSPolicy +from ._models_py3 import StorageQoSPolicyDetails +from ._models_py3 import SystemData +from ._models_py3 import VMMServer +from ._models_py3 import VMMServerListResult +from ._models_py3 import VMMServerPropertiesCredentials +from ._models_py3 import VirtualDisk +from ._models_py3 import VirtualDiskUpdate +from ._models_py3 import VirtualMachine +from ._models_py3 import VirtualMachineCreateCheckpoint +from ._models_py3 import VirtualMachineDeleteCheckpoint +from ._models_py3 import VirtualMachineInventoryItem +from ._models_py3 import VirtualMachineListResult +from ._models_py3 import VirtualMachineRestoreCheckpoint +from ._models_py3 import VirtualMachineTemplate +from ._models_py3 import VirtualMachineTemplateInventoryItem +from ._models_py3 import VirtualMachineTemplateListResult +from ._models_py3 import VirtualMachineUpdate +from ._models_py3 import VirtualMachineUpdateProperties +from ._models_py3 import VirtualNetwork +from ._models_py3 import VirtualNetworkInventoryItem +from ._models_py3 import VirtualNetworkListResult + + +from ._scvmm_enums import ( + AllocationMethod, + CreateDiffDisk, + CreatedByType, + DynamicMemoryEnabled, + InventoryType, + IsCustomizable, + LimitCpuForMigration, + OsType, +) + +__all__ = [ + 'AvailabilitySet', + 'AvailabilitySetListItem', + 'AvailabilitySetListResult', + 'Checkpoint', + 'Cloud', + 'CloudCapacity', + 'CloudInventoryItem', + 'CloudListResult', + 'ErrorDefinition', + 'ErrorResponse', + 'ExtendedLocation', + 'HardwareProfile', + 'HardwareProfileUpdate', + 'InventoryItem', + 'InventoryItemDetails', + 'InventoryItemProperties', + 'InventoryItemsList', + 'NetworkInterfaces', + 'NetworkInterfacesUpdate', + 'NetworkProfile', + 'NetworkProfileUpdate', + 'OsProfile', + 'ProxyResource', + 'Resource', + 'ResourcePatch', + 'ResourceProviderOperation', + 'ResourceProviderOperationDisplay', + 'ResourceProviderOperationList', + 'StopVirtualMachineOptions', + 'StorageProfile', + 'StorageProfileUpdate', + 'StorageQoSPolicy', + 'StorageQoSPolicyDetails', + 'SystemData', + 'VMMServer', + 'VMMServerListResult', + 'VMMServerPropertiesCredentials', + 'VirtualDisk', + 'VirtualDiskUpdate', + 'VirtualMachine', + 'VirtualMachineCreateCheckpoint', + 'VirtualMachineDeleteCheckpoint', + 'VirtualMachineInventoryItem', + 'VirtualMachineListResult', + 'VirtualMachineRestoreCheckpoint', + 'VirtualMachineTemplate', + 'VirtualMachineTemplateInventoryItem', + 'VirtualMachineTemplateListResult', + 'VirtualMachineUpdate', + 'VirtualMachineUpdateProperties', + 'VirtualNetwork', + 'VirtualNetworkInventoryItem', + 'VirtualNetworkListResult', + 'AllocationMethod', + 'CreateDiffDisk', + 'CreatedByType', + 'DynamicMemoryEnabled', + 'InventoryType', + 'IsCustomizable', + 'LimitCpuForMigration', + 'OsType', +] diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_models_py3.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_models_py3.py new file mode 100644 index 000000000000..85214b208446 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_models_py3.py @@ -0,0 +1,2875 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._scvmm_enums import * + + +class AvailabilitySet(msrest.serialization.Model): + """The AvailabilitySets resource definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :ivar type: Resource Type. + :vartype type: str + :ivar location: Gets or sets the location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.scvmm.models.SystemData + :ivar extended_location: The extended location. + :vartype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :ivar availability_set_name: Name of the availability set. + :vartype availability_set_name: str + :ivar vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :vartype vmm_server_id: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'availability_set_name': {'min_length': 1}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'availability_set_name': {'key': 'properties.availabilitySetName', 'type': 'str'}, + 'vmm_server_id': {'key': 'properties.vmmServerId', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + extended_location: Optional["ExtendedLocation"] = None, + availability_set_name: Optional[str] = None, + vmm_server_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword extended_location: The extended location. + :paramtype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :keyword availability_set_name: Name of the availability set. + :paramtype availability_set_name: str + :keyword vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :paramtype vmm_server_id: str + """ + super(AvailabilitySet, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + self.extended_location = extended_location + self.availability_set_name = availability_set_name + self.vmm_server_id = vmm_server_id + self.provisioning_state = None + + +class AvailabilitySetListItem(msrest.serialization.Model): + """Availability Set model. + + :ivar id: Gets the ARM Id of the microsoft.scvmm/availabilitySets resource. + :vartype id: str + :ivar name: Gets or sets the name of the availability set. + :vartype name: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Gets the ARM Id of the microsoft.scvmm/availabilitySets resource. + :paramtype id: str + :keyword name: Gets or sets the name of the availability set. + :paramtype name: str + """ + super(AvailabilitySetListItem, self).__init__(**kwargs) + self.id = id + self.name = name + + +class AvailabilitySetListResult(msrest.serialization.Model): + """List of AvailabilitySets. + + :ivar value: List of AvailabilitySets. + :vartype value: list[~azure.mgmt.scvmm.models.AvailabilitySet] + :ivar next_link: Url to follow for getting next page of resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AvailabilitySet]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AvailabilitySet"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of AvailabilitySets. + :paramtype value: list[~azure.mgmt.scvmm.models.AvailabilitySet] + :keyword next_link: Url to follow for getting next page of resources. + :paramtype next_link: str + """ + super(AvailabilitySetListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Checkpoint(msrest.serialization.Model): + """Defines the resource properties. + + :ivar parent_checkpoint_id: Gets ID of parent of the checkpoint. + :vartype parent_checkpoint_id: str + :ivar checkpoint_id: Gets ID of the checkpoint. + :vartype checkpoint_id: str + :ivar name: Gets name of the checkpoint. + :vartype name: str + :ivar description: Gets description of the checkpoint. + :vartype description: str + """ + + _attribute_map = { + 'parent_checkpoint_id': {'key': 'parentCheckpointID', 'type': 'str'}, + 'checkpoint_id': {'key': 'checkpointID', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + parent_checkpoint_id: Optional[str] = None, + checkpoint_id: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword parent_checkpoint_id: Gets ID of parent of the checkpoint. + :paramtype parent_checkpoint_id: str + :keyword checkpoint_id: Gets ID of the checkpoint. + :paramtype checkpoint_id: str + :keyword name: Gets name of the checkpoint. + :paramtype name: str + :keyword description: Gets description of the checkpoint. + :paramtype description: str + """ + super(Checkpoint, self).__init__(**kwargs) + self.parent_checkpoint_id = parent_checkpoint_id + self.checkpoint_id = checkpoint_id + self.name = name + self.description = description + + +class Cloud(msrest.serialization.Model): + """The Clouds resource definition. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :ivar type: Resource Type. + :vartype type: str + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.scvmm.models.SystemData + :ivar extended_location: Required. The extended location. + :vartype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource. + :vartype inventory_item_id: str + :ivar uuid: Unique ID of the cloud. + :vartype uuid: str + :ivar vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :vartype vmm_server_id: str + :ivar cloud_name: Name of the cloud in VMMServer. + :vartype cloud_name: str + :ivar cloud_capacity: Capacity of the cloud. + :vartype cloud_capacity: ~azure.mgmt.scvmm.models.CloudCapacity + :ivar storage_qo_s_policies: List of QoS policies available for the cloud. + :vartype storage_qo_s_policies: list[~azure.mgmt.scvmm.models.StorageQoSPolicy] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'extended_location': {'required': True}, + 'uuid': {'min_length': 1}, + 'cloud_name': {'readonly': True}, + 'cloud_capacity': {'readonly': True}, + 'storage_qo_s_policies': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'vmm_server_id': {'key': 'properties.vmmServerId', 'type': 'str'}, + 'cloud_name': {'key': 'properties.cloudName', 'type': 'str'}, + 'cloud_capacity': {'key': 'properties.cloudCapacity', 'type': 'CloudCapacity'}, + 'storage_qo_s_policies': {'key': 'properties.storageQoSPolicies', 'type': '[StorageQoSPolicy]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: "ExtendedLocation", + tags: Optional[Dict[str, str]] = None, + inventory_item_id: Optional[str] = None, + uuid: Optional[str] = None, + vmm_server_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword extended_location: Required. The extended location. + :paramtype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource. + :paramtype inventory_item_id: str + :keyword uuid: Unique ID of the cloud. + :paramtype uuid: str + :keyword vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :paramtype vmm_server_id: str + """ + super(Cloud, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + self.extended_location = extended_location + self.inventory_item_id = inventory_item_id + self.uuid = uuid + self.vmm_server_id = vmm_server_id + self.cloud_name = None + self.cloud_capacity = None + self.storage_qo_s_policies = None + self.provisioning_state = None + + +class CloudCapacity(msrest.serialization.Model): + """Cloud Capacity model. + + :ivar cpu_count: CPUCount specifies the maximum number of CPUs that can be allocated in the + cloud. + :vartype cpu_count: long + :ivar memory_mb: MemoryMB specifies a memory usage limit in megabytes. + :vartype memory_mb: long + :ivar vm_count: VMCount gives the max number of VMs that can be deployed in the cloud. + :vartype vm_count: long + """ + + _attribute_map = { + 'cpu_count': {'key': 'cpuCount', 'type': 'long'}, + 'memory_mb': {'key': 'memoryMB', 'type': 'long'}, + 'vm_count': {'key': 'vmCount', 'type': 'long'}, + } + + def __init__( + self, + *, + cpu_count: Optional[int] = None, + memory_mb: Optional[int] = None, + vm_count: Optional[int] = None, + **kwargs + ): + """ + :keyword cpu_count: CPUCount specifies the maximum number of CPUs that can be allocated in the + cloud. + :paramtype cpu_count: long + :keyword memory_mb: MemoryMB specifies a memory usage limit in megabytes. + :paramtype memory_mb: long + :keyword vm_count: VMCount gives the max number of VMs that can be deployed in the cloud. + :paramtype vm_count: long + """ + super(CloudCapacity, self).__init__(**kwargs) + self.cpu_count = cpu_count + self.memory_mb = memory_mb + self.vm_count = vm_count + + +class InventoryItemProperties(msrest.serialization.Model): + """Defines the resource properties. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: CloudInventoryItem, VirtualMachineInventoryItem, VirtualMachineTemplateInventoryItem, VirtualNetworkInventoryItem. + + 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 inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "Cloud", "VirtualNetwork", "VirtualMachineTemplate", "VirtualMachine". + :vartype inventory_type: str or ~azure.mgmt.scvmm.models.InventoryType + :ivar managed_resource_id: Gets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar uuid: Gets the UUID (which is assigned by VMM) for the inventory item. + :vartype uuid: str + :ivar inventory_item_name: Gets the Managed Object name in VMM for the inventory item. + :vartype inventory_item_name: str + :ivar provisioning_state: Gets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'managed_resource_id': {'readonly': True}, + 'uuid': {'readonly': True}, + 'inventory_item_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'uuid': {'key': 'uuid', 'type': 'str'}, + 'inventory_item_name': {'key': 'inventoryItemName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + _subtype_map = { + 'inventory_type': {'Cloud': 'CloudInventoryItem', 'VirtualMachine': 'VirtualMachineInventoryItem', 'VirtualMachineTemplate': 'VirtualMachineTemplateInventoryItem', 'VirtualNetwork': 'VirtualNetworkInventoryItem'} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(InventoryItemProperties, self).__init__(**kwargs) + self.inventory_type = None # type: Optional[str] + self.managed_resource_id = None + self.uuid = None + self.inventory_item_name = None + self.provisioning_state = None + + +class CloudInventoryItem(InventoryItemProperties): + """The Cloud inventory item. + + 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 inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "Cloud", "VirtualNetwork", "VirtualMachineTemplate", "VirtualMachine". + :vartype inventory_type: str or ~azure.mgmt.scvmm.models.InventoryType + :ivar managed_resource_id: Gets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar uuid: Gets the UUID (which is assigned by VMM) for the inventory item. + :vartype uuid: str + :ivar inventory_item_name: Gets the Managed Object name in VMM for the inventory item. + :vartype inventory_item_name: str + :ivar provisioning_state: Gets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'managed_resource_id': {'readonly': True}, + 'uuid': {'readonly': True}, + 'inventory_item_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'uuid': {'key': 'uuid', 'type': 'str'}, + 'inventory_item_name': {'key': 'inventoryItemName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(CloudInventoryItem, self).__init__(**kwargs) + self.inventory_type = 'Cloud' # type: str + + +class CloudListResult(msrest.serialization.Model): + """List of Clouds. + + :ivar value: List of Clouds. + :vartype value: list[~azure.mgmt.scvmm.models.Cloud] + :ivar next_link: Url to follow for getting next page of resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Cloud]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Cloud"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of Clouds. + :paramtype value: list[~azure.mgmt.scvmm.models.Cloud] + :keyword next_link: Url to follow for getting next page of resources. + :paramtype next_link: str + """ + super(CloudListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ErrorDefinition(msrest.serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.scvmm.models.ErrorDefinition] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorDefinition, self).__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :ivar error: The error details. + :vartype error: ~azure.mgmt.scvmm.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinition"] = None, + **kwargs + ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.scvmm.models.ErrorDefinition + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ExtendedLocation(msrest.serialization.Model): + """The extended location. + + :ivar type: The extended location type. + :vartype type: str + :ivar name: The extended location name. + :vartype name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + name: Optional[str] = None, + **kwargs + ): + """ + :keyword type: The extended location type. + :paramtype type: str + :keyword name: The extended location name. + :paramtype name: str + """ + super(ExtendedLocation, self).__init__(**kwargs) + self.type = type + self.name = name + + +class HardwareProfile(msrest.serialization.Model): + """Defines the resource properties. + + :ivar memory_mb: MemoryMB is the size of a virtual machine's memory, in MB. + :vartype memory_mb: int + :ivar cpu_count: Gets or sets the number of vCPUs for the vm. + :vartype cpu_count: int + :ivar limit_cpu_for_migration: Gets or sets a value indicating whether to enable processor + compatibility mode for live migration of VMs. Possible values include: "false", "true". + :vartype limit_cpu_for_migration: str or ~azure.mgmt.scvmm.models.LimitCpuForMigration + :ivar dynamic_memory_enabled: Gets or sets a value indicating whether to enable dynamic memory + or not. Possible values include: "false", "true". + :vartype dynamic_memory_enabled: str or ~azure.mgmt.scvmm.models.DynamicMemoryEnabled + :ivar dynamic_memory_max_mb: Gets or sets the max dynamic memory for the vm. + :vartype dynamic_memory_max_mb: int + :ivar dynamic_memory_min_mb: Gets or sets the min dynamic memory for the vm. + :vartype dynamic_memory_min_mb: int + :ivar is_highly_available: Gets highly available property. + :vartype is_highly_available: str + """ + + _attribute_map = { + 'memory_mb': {'key': 'memoryMB', 'type': 'int'}, + 'cpu_count': {'key': 'cpuCount', 'type': 'int'}, + 'limit_cpu_for_migration': {'key': 'limitCpuForMigration', 'type': 'str'}, + 'dynamic_memory_enabled': {'key': 'dynamicMemoryEnabled', 'type': 'str'}, + 'dynamic_memory_max_mb': {'key': 'dynamicMemoryMaxMB', 'type': 'int'}, + 'dynamic_memory_min_mb': {'key': 'dynamicMemoryMinMB', 'type': 'int'}, + 'is_highly_available': {'key': 'isHighlyAvailable', 'type': 'str'}, + } + + def __init__( + self, + *, + memory_mb: Optional[int] = None, + cpu_count: Optional[int] = None, + limit_cpu_for_migration: Optional[Union[str, "LimitCpuForMigration"]] = None, + dynamic_memory_enabled: Optional[Union[str, "DynamicMemoryEnabled"]] = None, + dynamic_memory_max_mb: Optional[int] = None, + dynamic_memory_min_mb: Optional[int] = None, + is_highly_available: Optional[str] = None, + **kwargs + ): + """ + :keyword memory_mb: MemoryMB is the size of a virtual machine's memory, in MB. + :paramtype memory_mb: int + :keyword cpu_count: Gets or sets the number of vCPUs for the vm. + :paramtype cpu_count: int + :keyword limit_cpu_for_migration: Gets or sets a value indicating whether to enable processor + compatibility mode for live migration of VMs. Possible values include: "false", "true". + :paramtype limit_cpu_for_migration: str or ~azure.mgmt.scvmm.models.LimitCpuForMigration + :keyword dynamic_memory_enabled: Gets or sets a value indicating whether to enable dynamic + memory or not. Possible values include: "false", "true". + :paramtype dynamic_memory_enabled: str or ~azure.mgmt.scvmm.models.DynamicMemoryEnabled + :keyword dynamic_memory_max_mb: Gets or sets the max dynamic memory for the vm. + :paramtype dynamic_memory_max_mb: int + :keyword dynamic_memory_min_mb: Gets or sets the min dynamic memory for the vm. + :paramtype dynamic_memory_min_mb: int + :keyword is_highly_available: Gets highly available property. + :paramtype is_highly_available: str + """ + super(HardwareProfile, self).__init__(**kwargs) + self.memory_mb = memory_mb + self.cpu_count = cpu_count + self.limit_cpu_for_migration = limit_cpu_for_migration + self.dynamic_memory_enabled = dynamic_memory_enabled + self.dynamic_memory_max_mb = dynamic_memory_max_mb + self.dynamic_memory_min_mb = dynamic_memory_min_mb + self.is_highly_available = is_highly_available + + +class HardwareProfileUpdate(msrest.serialization.Model): + """Defines the resource properties. + + :ivar memory_mb: MemoryMB is the size of a virtual machine's memory, in MB. + :vartype memory_mb: int + :ivar cpu_count: Gets or sets the number of vCPUs for the vm. + :vartype cpu_count: int + :ivar limit_cpu_for_migration: Gets or sets a value indicating whether to enable processor + compatibility mode for live migration of VMs. Possible values include: "false", "true". + :vartype limit_cpu_for_migration: str or ~azure.mgmt.scvmm.models.LimitCpuForMigration + :ivar dynamic_memory_enabled: Gets or sets a value indicating whether to enable dynamic memory + or not. Possible values include: "false", "true". + :vartype dynamic_memory_enabled: str or ~azure.mgmt.scvmm.models.DynamicMemoryEnabled + :ivar dynamic_memory_max_mb: Gets or sets the max dynamic memory for the vm. + :vartype dynamic_memory_max_mb: int + :ivar dynamic_memory_min_mb: Gets or sets the min dynamic memory for the vm. + :vartype dynamic_memory_min_mb: int + """ + + _attribute_map = { + 'memory_mb': {'key': 'memoryMB', 'type': 'int'}, + 'cpu_count': {'key': 'cpuCount', 'type': 'int'}, + 'limit_cpu_for_migration': {'key': 'limitCpuForMigration', 'type': 'str'}, + 'dynamic_memory_enabled': {'key': 'dynamicMemoryEnabled', 'type': 'str'}, + 'dynamic_memory_max_mb': {'key': 'dynamicMemoryMaxMB', 'type': 'int'}, + 'dynamic_memory_min_mb': {'key': 'dynamicMemoryMinMB', 'type': 'int'}, + } + + def __init__( + self, + *, + memory_mb: Optional[int] = None, + cpu_count: Optional[int] = None, + limit_cpu_for_migration: Optional[Union[str, "LimitCpuForMigration"]] = None, + dynamic_memory_enabled: Optional[Union[str, "DynamicMemoryEnabled"]] = None, + dynamic_memory_max_mb: Optional[int] = None, + dynamic_memory_min_mb: Optional[int] = None, + **kwargs + ): + """ + :keyword memory_mb: MemoryMB is the size of a virtual machine's memory, in MB. + :paramtype memory_mb: int + :keyword cpu_count: Gets or sets the number of vCPUs for the vm. + :paramtype cpu_count: int + :keyword limit_cpu_for_migration: Gets or sets a value indicating whether to enable processor + compatibility mode for live migration of VMs. Possible values include: "false", "true". + :paramtype limit_cpu_for_migration: str or ~azure.mgmt.scvmm.models.LimitCpuForMigration + :keyword dynamic_memory_enabled: Gets or sets a value indicating whether to enable dynamic + memory or not. Possible values include: "false", "true". + :paramtype dynamic_memory_enabled: str or ~azure.mgmt.scvmm.models.DynamicMemoryEnabled + :keyword dynamic_memory_max_mb: Gets or sets the max dynamic memory for the vm. + :paramtype dynamic_memory_max_mb: int + :keyword dynamic_memory_min_mb: Gets or sets the min dynamic memory for the vm. + :paramtype dynamic_memory_min_mb: int + """ + super(HardwareProfileUpdate, self).__init__(**kwargs) + self.memory_mb = memory_mb + self.cpu_count = cpu_count + self.limit_cpu_for_migration = limit_cpu_for_migration + self.dynamic_memory_enabled = dynamic_memory_enabled + self.dynamic_memory_max_mb = dynamic_memory_max_mb + self.dynamic_memory_min_mb = dynamic_memory_min_mb + + +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 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 InventoryItem(ProxyResource): + """Defines the inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.scvmm.models.SystemData + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "Cloud", "VirtualNetwork", "VirtualMachineTemplate", "VirtualMachine". + :vartype inventory_type: str or ~azure.mgmt.scvmm.models.InventoryType + :ivar managed_resource_id: Gets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar uuid: Gets the UUID (which is assigned by VMM) for the inventory item. + :vartype uuid: str + :ivar inventory_item_name: Gets the Managed Object name in VMM for the inventory item. + :vartype inventory_item_name: str + :ivar provisioning_state: Gets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'inventory_type': {'required': True}, + 'managed_resource_id': {'readonly': True}, + 'uuid': {'readonly': True}, + 'inventory_item_name': {'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'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'inventory_type': {'key': 'properties.inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'properties.managedResourceId', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'inventory_item_name': {'key': 'properties.inventoryItemName', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + kind: Optional[str] = None, + **kwargs + ): + """ + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + """ + super(InventoryItem, self).__init__(**kwargs) + self.system_data = None + self.kind = kind + self.inventory_type = None # type: Optional[str] + self.managed_resource_id = None + self.uuid = None + self.inventory_item_name = None + self.provisioning_state = None + + +class InventoryItemDetails(msrest.serialization.Model): + """Defines the resource properties. + + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource. + :vartype inventory_item_id: str + :ivar inventory_item_name: Gets or sets the Managed Object name in VMM for the resource. + :vartype inventory_item_name: str + """ + + _attribute_map = { + 'inventory_item_id': {'key': 'inventoryItemId', 'type': 'str'}, + 'inventory_item_name': {'key': 'inventoryItemName', 'type': 'str'}, + } + + def __init__( + self, + *, + inventory_item_id: Optional[str] = None, + inventory_item_name: Optional[str] = None, + **kwargs + ): + """ + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource. + :paramtype inventory_item_id: str + :keyword inventory_item_name: Gets or sets the Managed Object name in VMM for the resource. + :paramtype inventory_item_name: str + """ + super(InventoryItemDetails, self).__init__(**kwargs) + self.inventory_item_id = inventory_item_id + self.inventory_item_name = inventory_item_name + + +class InventoryItemsList(msrest.serialization.Model): + """List of InventoryItems. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of InventoryItems. + :vartype next_link: str + :ivar value: Required. Array of InventoryItems. + :vartype value: list[~azure.mgmt.scvmm.models.InventoryItem] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[InventoryItem]'}, + } + + def __init__( + self, + *, + value: List["InventoryItem"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of InventoryItems. + :paramtype next_link: str + :keyword value: Required. Array of InventoryItems. + :paramtype value: list[~azure.mgmt.scvmm.models.InventoryItem] + """ + super(InventoryItemsList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class NetworkInterfaces(msrest.serialization.Model): + """Network Interface model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Gets or sets the name of the network interface. + :vartype name: str + :ivar display_name: Gets the display name of the network interface as shown in the vmmServer. + This is the fallback label for a NIC when the name is not set. + :vartype display_name: str + :ivar ipv4_addresses: Gets or sets the nic ipv4 addresses. + :vartype ipv4_addresses: list[str] + :ivar ipv6_addresses: Gets or sets the nic ipv6 addresses. + :vartype ipv6_addresses: list[str] + :ivar mac_address: Gets or sets the nic MAC address. + :vartype mac_address: str + :ivar virtual_network_id: Gets or sets the ARM Id of the Microsoft.ScVmm/virtualNetwork + resource to connect the nic. + :vartype virtual_network_id: str + :ivar network_name: Gets or sets the name of the virtual network in vmmServer that the nic is + connected to. + :vartype network_name: str + :ivar ipv4_address_type: Gets or sets the ipv4 address type. Possible values include: + "Dynamic", "Static". + :vartype ipv4_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :ivar ipv6_address_type: Gets or sets the ipv6 address type. Possible values include: + "Dynamic", "Static". + :vartype ipv6_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :ivar mac_address_type: Gets or sets the mac address type. Possible values include: "Dynamic", + "Static". + :vartype mac_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :ivar nic_id: Gets or sets the nic id. + :vartype nic_id: str + """ + + _validation = { + 'display_name': {'readonly': True}, + 'ipv4_addresses': {'readonly': True}, + 'ipv6_addresses': {'readonly': True}, + 'network_name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'ipv4_addresses': {'key': 'ipv4Addresses', 'type': '[str]'}, + 'ipv6_addresses': {'key': 'ipv6Addresses', 'type': '[str]'}, + 'mac_address': {'key': 'macAddress', 'type': 'str'}, + 'virtual_network_id': {'key': 'virtualNetworkId', 'type': 'str'}, + 'network_name': {'key': 'networkName', 'type': 'str'}, + 'ipv4_address_type': {'key': 'ipv4AddressType', 'type': 'str'}, + 'ipv6_address_type': {'key': 'ipv6AddressType', 'type': 'str'}, + 'mac_address_type': {'key': 'macAddressType', 'type': 'str'}, + 'nic_id': {'key': 'nicId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + mac_address: Optional[str] = None, + virtual_network_id: Optional[str] = None, + ipv4_address_type: Optional[Union[str, "AllocationMethod"]] = None, + ipv6_address_type: Optional[Union[str, "AllocationMethod"]] = None, + mac_address_type: Optional[Union[str, "AllocationMethod"]] = None, + nic_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the network interface. + :paramtype name: str + :keyword mac_address: Gets or sets the nic MAC address. + :paramtype mac_address: str + :keyword virtual_network_id: Gets or sets the ARM Id of the Microsoft.ScVmm/virtualNetwork + resource to connect the nic. + :paramtype virtual_network_id: str + :keyword ipv4_address_type: Gets or sets the ipv4 address type. Possible values include: + "Dynamic", "Static". + :paramtype ipv4_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :keyword ipv6_address_type: Gets or sets the ipv6 address type. Possible values include: + "Dynamic", "Static". + :paramtype ipv6_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :keyword mac_address_type: Gets or sets the mac address type. Possible values include: + "Dynamic", "Static". + :paramtype mac_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :keyword nic_id: Gets or sets the nic id. + :paramtype nic_id: str + """ + super(NetworkInterfaces, self).__init__(**kwargs) + self.name = name + self.display_name = None + self.ipv4_addresses = None + self.ipv6_addresses = None + self.mac_address = mac_address + self.virtual_network_id = virtual_network_id + self.network_name = None + self.ipv4_address_type = ipv4_address_type + self.ipv6_address_type = ipv6_address_type + self.mac_address_type = mac_address_type + self.nic_id = nic_id + + +class NetworkInterfacesUpdate(msrest.serialization.Model): + """Network Interface model. + + :ivar name: Gets or sets the name of the network interface. + :vartype name: str + :ivar mac_address: Gets or sets the nic MAC address. + :vartype mac_address: str + :ivar virtual_network_id: Gets or sets the ARM Id of the Microsoft.ScVmm/virtualNetwork + resource to connect the nic. + :vartype virtual_network_id: str + :ivar ipv4_address_type: Gets or sets the ipv4 address type. Possible values include: + "Dynamic", "Static". + :vartype ipv4_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :ivar ipv6_address_type: Gets or sets the ipv6 address type. Possible values include: + "Dynamic", "Static". + :vartype ipv6_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :ivar mac_address_type: Gets or sets the mac address type. Possible values include: "Dynamic", + "Static". + :vartype mac_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :ivar nic_id: Gets or sets the nic id. + :vartype nic_id: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'mac_address': {'key': 'macAddress', 'type': 'str'}, + 'virtual_network_id': {'key': 'virtualNetworkId', 'type': 'str'}, + 'ipv4_address_type': {'key': 'ipv4AddressType', 'type': 'str'}, + 'ipv6_address_type': {'key': 'ipv6AddressType', 'type': 'str'}, + 'mac_address_type': {'key': 'macAddressType', 'type': 'str'}, + 'nic_id': {'key': 'nicId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + mac_address: Optional[str] = None, + virtual_network_id: Optional[str] = None, + ipv4_address_type: Optional[Union[str, "AllocationMethod"]] = None, + ipv6_address_type: Optional[Union[str, "AllocationMethod"]] = None, + mac_address_type: Optional[Union[str, "AllocationMethod"]] = None, + nic_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the network interface. + :paramtype name: str + :keyword mac_address: Gets or sets the nic MAC address. + :paramtype mac_address: str + :keyword virtual_network_id: Gets or sets the ARM Id of the Microsoft.ScVmm/virtualNetwork + resource to connect the nic. + :paramtype virtual_network_id: str + :keyword ipv4_address_type: Gets or sets the ipv4 address type. Possible values include: + "Dynamic", "Static". + :paramtype ipv4_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :keyword ipv6_address_type: Gets or sets the ipv6 address type. Possible values include: + "Dynamic", "Static". + :paramtype ipv6_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :keyword mac_address_type: Gets or sets the mac address type. Possible values include: + "Dynamic", "Static". + :paramtype mac_address_type: str or ~azure.mgmt.scvmm.models.AllocationMethod + :keyword nic_id: Gets or sets the nic id. + :paramtype nic_id: str + """ + super(NetworkInterfacesUpdate, self).__init__(**kwargs) + self.name = name + self.mac_address = mac_address + self.virtual_network_id = virtual_network_id + self.ipv4_address_type = ipv4_address_type + self.ipv6_address_type = ipv6_address_type + self.mac_address_type = mac_address_type + self.nic_id = nic_id + + +class NetworkProfile(msrest.serialization.Model): + """Defines the resource properties. + + :ivar network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :vartype network_interfaces: list[~azure.mgmt.scvmm.models.NetworkInterfaces] + """ + + _attribute_map = { + 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterfaces]'}, + } + + def __init__( + self, + *, + network_interfaces: Optional[List["NetworkInterfaces"]] = None, + **kwargs + ): + """ + :keyword network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :paramtype network_interfaces: list[~azure.mgmt.scvmm.models.NetworkInterfaces] + """ + super(NetworkProfile, self).__init__(**kwargs) + self.network_interfaces = network_interfaces + + +class NetworkProfileUpdate(msrest.serialization.Model): + """Defines the resource properties. + + :ivar network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :vartype network_interfaces: list[~azure.mgmt.scvmm.models.NetworkInterfacesUpdate] + """ + + _attribute_map = { + 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterfacesUpdate]'}, + } + + def __init__( + self, + *, + network_interfaces: Optional[List["NetworkInterfacesUpdate"]] = None, + **kwargs + ): + """ + :keyword network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :paramtype network_interfaces: list[~azure.mgmt.scvmm.models.NetworkInterfacesUpdate] + """ + super(NetworkProfileUpdate, self).__init__(**kwargs) + self.network_interfaces = network_interfaces + + +class OsProfile(msrest.serialization.Model): + """Defines the resource properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar admin_password: Admin password of the virtual machine. + :vartype admin_password: str + :ivar computer_name: Gets or sets computer name. + :vartype computer_name: str + :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + "Other". + :vartype os_type: str or ~azure.mgmt.scvmm.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + """ + + _validation = { + 'os_type': {'readonly': True}, + 'os_name': {'readonly': True}, + } + + _attribute_map = { + 'admin_password': {'key': 'adminPassword', 'type': 'str'}, + 'computer_name': {'key': 'computerName', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'os_name': {'key': 'osName', 'type': 'str'}, + } + + def __init__( + self, + *, + admin_password: Optional[str] = None, + computer_name: Optional[str] = None, + **kwargs + ): + """ + :keyword admin_password: Admin password of the virtual machine. + :paramtype admin_password: str + :keyword computer_name: Gets or sets computer name. + :paramtype computer_name: str + """ + super(OsProfile, self).__init__(**kwargs) + self.admin_password = admin_password + self.computer_name = computer_name + self.os_type = None + self.os_name = None + + +class ResourcePatch(msrest.serialization.Model): + """Object containing tags updates for patch operations. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(ResourcePatch, self).__init__(**kwargs) + self.tags = tags + + +class ResourceProviderOperation(msrest.serialization.Model): + """Results of the request to list operations. + + :ivar is_data_action: Indicates whether the operation applies to data-plane. + :vartype is_data_action: str + :ivar name: Operation name, in format of {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.scvmm.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__( + self, + *, + is_data_action: Optional[str] = None, + name: Optional[str] = None, + display: Optional["ResourceProviderOperationDisplay"] = None, + **kwargs + ): + """ + :keyword is_data_action: Indicates whether the operation applies to data-plane. + :paramtype is_data_action: str + :keyword name: Operation name, in format of {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.scvmm.models.ResourceProviderOperationDisplay + """ + super(ResourceProviderOperation, self).__init__(**kwargs) + self.is_data_action = is_data_action + self.name = name + self.display = display + + +class ResourceProviderOperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: The resource provider. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Type of operation: read, write, delete, etc. + :vartype operation: str + :ivar description: Description of this operation. + :vartype description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: The resource provider. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + :keyword operation: Type of operation: read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of this operation. + :paramtype description: str + """ + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(msrest.serialization.Model): + """Results of the request to list operations. + + :ivar value: List of Operations. + :vartype value: list[~azure.mgmt.scvmm.models.ResourceProviderOperation] + :ivar next_link: Url to follow for getting next page of resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceProviderOperation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of Operations. + :paramtype value: list[~azure.mgmt.scvmm.models.ResourceProviderOperation] + :keyword next_link: Url to follow for getting next page of resources. + :paramtype next_link: str + """ + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class StopVirtualMachineOptions(msrest.serialization.Model): + """Defines the stop action properties. + + :ivar skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM + shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates + otherwise. Defaults to false. + :vartype skip_shutdown: bool + """ + + _attribute_map = { + 'skip_shutdown': {'key': 'skipShutdown', 'type': 'bool'}, + } + + def __init__( + self, + *, + skip_shutdown: Optional[bool] = False, + **kwargs + ): + """ + :keyword skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM + shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates + otherwise. Defaults to false. + :paramtype skip_shutdown: bool + """ + super(StopVirtualMachineOptions, self).__init__(**kwargs) + self.skip_shutdown = skip_shutdown + + +class StorageProfile(msrest.serialization.Model): + """Defines the resource properties. + + :ivar disks: Gets or sets the list of virtual disks associated with the virtual machine. + :vartype disks: list[~azure.mgmt.scvmm.models.VirtualDisk] + """ + + _attribute_map = { + 'disks': {'key': 'disks', 'type': '[VirtualDisk]'}, + } + + def __init__( + self, + *, + disks: Optional[List["VirtualDisk"]] = None, + **kwargs + ): + """ + :keyword disks: Gets or sets the list of virtual disks associated with the virtual machine. + :paramtype disks: list[~azure.mgmt.scvmm.models.VirtualDisk] + """ + super(StorageProfile, self).__init__(**kwargs) + self.disks = disks + + +class StorageProfileUpdate(msrest.serialization.Model): + """Defines the resource properties. + + :ivar disks: Gets or sets the list of virtual disks associated with the virtual machine. + :vartype disks: list[~azure.mgmt.scvmm.models.VirtualDiskUpdate] + """ + + _attribute_map = { + 'disks': {'key': 'disks', 'type': '[VirtualDiskUpdate]'}, + } + + def __init__( + self, + *, + disks: Optional[List["VirtualDiskUpdate"]] = None, + **kwargs + ): + """ + :keyword disks: Gets or sets the list of virtual disks associated with the virtual machine. + :paramtype disks: list[~azure.mgmt.scvmm.models.VirtualDiskUpdate] + """ + super(StorageProfileUpdate, self).__init__(**kwargs) + self.disks = disks + + +class StorageQoSPolicy(msrest.serialization.Model): + """The StorageQoSPolicy definition. + + :ivar name: The name of the policy. + :vartype name: str + :ivar id: The ID of the QoS policy. + :vartype id: str + :ivar iops_maximum: The maximum IO operations per second. + :vartype iops_maximum: long + :ivar iops_minimum: The minimum IO operations per second. + :vartype iops_minimum: long + :ivar bandwidth_limit: The Bandwidth Limit for internet traffic. + :vartype bandwidth_limit: long + :ivar policy_id: The underlying policy. + :vartype policy_id: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'iops_maximum': {'key': 'iopsMaximum', 'type': 'long'}, + 'iops_minimum': {'key': 'iopsMinimum', 'type': 'long'}, + 'bandwidth_limit': {'key': 'bandwidthLimit', 'type': 'long'}, + 'policy_id': {'key': 'policyId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, + iops_maximum: Optional[int] = None, + iops_minimum: Optional[int] = None, + bandwidth_limit: Optional[int] = None, + policy_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of the policy. + :paramtype name: str + :keyword id: The ID of the QoS policy. + :paramtype id: str + :keyword iops_maximum: The maximum IO operations per second. + :paramtype iops_maximum: long + :keyword iops_minimum: The minimum IO operations per second. + :paramtype iops_minimum: long + :keyword bandwidth_limit: The Bandwidth Limit for internet traffic. + :paramtype bandwidth_limit: long + :keyword policy_id: The underlying policy. + :paramtype policy_id: str + """ + super(StorageQoSPolicy, self).__init__(**kwargs) + self.name = name + self.id = id + self.iops_maximum = iops_maximum + self.iops_minimum = iops_minimum + self.bandwidth_limit = bandwidth_limit + self.policy_id = policy_id + + +class StorageQoSPolicyDetails(msrest.serialization.Model): + """The StorageQoSPolicyDetails definition. + + :ivar name: The name of the policy. + :vartype name: str + :ivar id: The ID of the QoS policy. + :vartype id: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of the policy. + :paramtype name: str + :keyword id: The ID of the QoS policy. + :paramtype id: str + """ + super(StorageQoSPolicyDetails, self).__init__(**kwargs) + self.name = name + self.id = id + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.scvmm.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.scvmm.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.scvmm.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.scvmm.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 + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class VirtualDisk(msrest.serialization.Model): + """Virtual disk model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Gets or sets the name of the disk. + :vartype name: str + :ivar display_name: Gets the display name of the virtual disk as shown in the vmmServer. This + is the fallback label for a disk when the name is not set. + :vartype display_name: str + :ivar disk_id: Gets or sets the disk id. + :vartype disk_id: str + :ivar disk_size_gb: Gets or sets the disk total size. + :vartype disk_size_gb: int + :ivar max_disk_size_gb: Gets or sets the max disk size. + :vartype max_disk_size_gb: int + :ivar bus: Gets or sets the disk bus. + :vartype bus: int + :ivar lun: Gets or sets the disk lun. + :vartype lun: int + :ivar bus_type: Gets or sets the disk bus type. + :vartype bus_type: str + :ivar vhd_type: Gets or sets the disk vhd type. + :vartype vhd_type: str + :ivar volume_type: Gets or sets the disk volume type. + :vartype volume_type: str + :ivar vhd_format_type: Gets the disk vhd format type. + :vartype vhd_format_type: str + :ivar template_disk_id: Gets or sets the disk id in the template. + :vartype template_disk_id: str + :ivar storage_qo_s_policy: The QoS policy for the disk. + :vartype storage_qo_s_policy: ~azure.mgmt.scvmm.models.StorageQoSPolicyDetails + :ivar create_diff_disk: Gets or sets a value indicating diff disk. Possible values include: + "false", "true". + :vartype create_diff_disk: str or ~azure.mgmt.scvmm.models.CreateDiffDisk + """ + + _validation = { + 'display_name': {'readonly': True}, + 'max_disk_size_gb': {'readonly': True}, + 'volume_type': {'readonly': True}, + 'vhd_format_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'disk_id': {'key': 'diskId', 'type': 'str'}, + 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, + 'max_disk_size_gb': {'key': 'maxDiskSizeGB', 'type': 'int'}, + 'bus': {'key': 'bus', 'type': 'int'}, + 'lun': {'key': 'lun', 'type': 'int'}, + 'bus_type': {'key': 'busType', 'type': 'str'}, + 'vhd_type': {'key': 'vhdType', 'type': 'str'}, + 'volume_type': {'key': 'volumeType', 'type': 'str'}, + 'vhd_format_type': {'key': 'vhdFormatType', 'type': 'str'}, + 'template_disk_id': {'key': 'templateDiskId', 'type': 'str'}, + 'storage_qo_s_policy': {'key': 'storageQoSPolicy', 'type': 'StorageQoSPolicyDetails'}, + 'create_diff_disk': {'key': 'createDiffDisk', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + disk_id: Optional[str] = None, + disk_size_gb: Optional[int] = None, + bus: Optional[int] = None, + lun: Optional[int] = None, + bus_type: Optional[str] = None, + vhd_type: Optional[str] = None, + template_disk_id: Optional[str] = None, + storage_qo_s_policy: Optional["StorageQoSPolicyDetails"] = None, + create_diff_disk: Optional[Union[str, "CreateDiffDisk"]] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the disk. + :paramtype name: str + :keyword disk_id: Gets or sets the disk id. + :paramtype disk_id: str + :keyword disk_size_gb: Gets or sets the disk total size. + :paramtype disk_size_gb: int + :keyword bus: Gets or sets the disk bus. + :paramtype bus: int + :keyword lun: Gets or sets the disk lun. + :paramtype lun: int + :keyword bus_type: Gets or sets the disk bus type. + :paramtype bus_type: str + :keyword vhd_type: Gets or sets the disk vhd type. + :paramtype vhd_type: str + :keyword template_disk_id: Gets or sets the disk id in the template. + :paramtype template_disk_id: str + :keyword storage_qo_s_policy: The QoS policy for the disk. + :paramtype storage_qo_s_policy: ~azure.mgmt.scvmm.models.StorageQoSPolicyDetails + :keyword create_diff_disk: Gets or sets a value indicating diff disk. Possible values include: + "false", "true". + :paramtype create_diff_disk: str or ~azure.mgmt.scvmm.models.CreateDiffDisk + """ + super(VirtualDisk, self).__init__(**kwargs) + self.name = name + self.display_name = None + self.disk_id = disk_id + self.disk_size_gb = disk_size_gb + self.max_disk_size_gb = None + self.bus = bus + self.lun = lun + self.bus_type = bus_type + self.vhd_type = vhd_type + self.volume_type = None + self.vhd_format_type = None + self.template_disk_id = template_disk_id + self.storage_qo_s_policy = storage_qo_s_policy + self.create_diff_disk = create_diff_disk + + +class VirtualDiskUpdate(msrest.serialization.Model): + """Virtual disk model. + + :ivar name: Gets or sets the name of the disk. + :vartype name: str + :ivar disk_id: Gets or sets the disk id. + :vartype disk_id: str + :ivar disk_size_gb: Gets or sets the disk total size. + :vartype disk_size_gb: int + :ivar bus: Gets or sets the disk bus. + :vartype bus: int + :ivar lun: Gets or sets the disk lun. + :vartype lun: int + :ivar bus_type: Gets or sets the disk bus type. + :vartype bus_type: str + :ivar vhd_type: Gets or sets the disk vhd type. + :vartype vhd_type: str + :ivar storage_qo_s_policy: The QoS policy for the disk. + :vartype storage_qo_s_policy: ~azure.mgmt.scvmm.models.StorageQoSPolicyDetails + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'disk_id': {'key': 'diskId', 'type': 'str'}, + 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, + 'bus': {'key': 'bus', 'type': 'int'}, + 'lun': {'key': 'lun', 'type': 'int'}, + 'bus_type': {'key': 'busType', 'type': 'str'}, + 'vhd_type': {'key': 'vhdType', 'type': 'str'}, + 'storage_qo_s_policy': {'key': 'storageQoSPolicy', 'type': 'StorageQoSPolicyDetails'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + disk_id: Optional[str] = None, + disk_size_gb: Optional[int] = None, + bus: Optional[int] = None, + lun: Optional[int] = None, + bus_type: Optional[str] = None, + vhd_type: Optional[str] = None, + storage_qo_s_policy: Optional["StorageQoSPolicyDetails"] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the disk. + :paramtype name: str + :keyword disk_id: Gets or sets the disk id. + :paramtype disk_id: str + :keyword disk_size_gb: Gets or sets the disk total size. + :paramtype disk_size_gb: int + :keyword bus: Gets or sets the disk bus. + :paramtype bus: int + :keyword lun: Gets or sets the disk lun. + :paramtype lun: int + :keyword bus_type: Gets or sets the disk bus type. + :paramtype bus_type: str + :keyword vhd_type: Gets or sets the disk vhd type. + :paramtype vhd_type: str + :keyword storage_qo_s_policy: The QoS policy for the disk. + :paramtype storage_qo_s_policy: ~azure.mgmt.scvmm.models.StorageQoSPolicyDetails + """ + super(VirtualDiskUpdate, self).__init__(**kwargs) + self.name = name + self.disk_id = disk_id + self.disk_size_gb = disk_size_gb + self.bus = bus + self.lun = lun + self.bus_type = bus_type + self.vhd_type = vhd_type + self.storage_qo_s_policy = storage_qo_s_policy + + +class VirtualMachine(msrest.serialization.Model): + """The VirtualMachines resource definition. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :ivar type: Resource Type. + :vartype type: str + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.scvmm.models.SystemData + :ivar extended_location: Required. The extended location. + :vartype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource. + :vartype inventory_item_id: str + :ivar vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :vartype vmm_server_id: str + :ivar cloud_id: ARM Id of the cloud resource to use for deploying the vm. + :vartype cloud_id: str + :ivar template_id: ARM Id of the template resource to use for deploying the vm. + :vartype template_id: str + :ivar checkpoint_type: Type of checkpoint supported for the vm. + :vartype checkpoint_type: str + :ivar checkpoints: Checkpoints in the vm. + :vartype checkpoints: list[~azure.mgmt.scvmm.models.Checkpoint] + :ivar availability_sets: Availability Sets in vm. + :vartype availability_sets: list[~azure.mgmt.scvmm.models.AvailabilitySetListItem] + :ivar os_profile: OS properties. + :vartype os_profile: ~azure.mgmt.scvmm.models.OsProfile + :ivar hardware_profile: Hardware properties. + :vartype hardware_profile: ~azure.mgmt.scvmm.models.HardwareProfile + :ivar network_profile: Network properties. + :vartype network_profile: ~azure.mgmt.scvmm.models.NetworkProfile + :ivar storage_profile: Storage properties. + :vartype storage_profile: ~azure.mgmt.scvmm.models.StorageProfile + :ivar vm_name: VMName is the name of VM on the SCVMM server. + :vartype vm_name: str + :ivar uuid: Unique ID of the virtual machine. + :vartype uuid: str + :ivar generation: Gets or sets the generation for the vm. + :vartype generation: int + :ivar power_state: Gets the power state of the virtual machine. + :vartype power_state: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'extended_location': {'required': True}, + 'vm_name': {'min_length': 1}, + 'power_state': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'vmm_server_id': {'key': 'properties.vmmServerId', 'type': 'str'}, + 'cloud_id': {'key': 'properties.cloudId', 'type': 'str'}, + 'template_id': {'key': 'properties.templateId', 'type': 'str'}, + 'checkpoint_type': {'key': 'properties.checkpointType', 'type': 'str'}, + 'checkpoints': {'key': 'properties.checkpoints', 'type': '[Checkpoint]'}, + 'availability_sets': {'key': 'properties.availabilitySets', 'type': '[AvailabilitySetListItem]'}, + 'os_profile': {'key': 'properties.osProfile', 'type': 'OsProfile'}, + 'hardware_profile': {'key': 'properties.hardwareProfile', 'type': 'HardwareProfile'}, + 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, + 'storage_profile': {'key': 'properties.storageProfile', 'type': 'StorageProfile'}, + 'vm_name': {'key': 'properties.vmName', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'generation': {'key': 'properties.generation', 'type': 'int'}, + 'power_state': {'key': 'properties.powerState', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: "ExtendedLocation", + tags: Optional[Dict[str, str]] = None, + inventory_item_id: Optional[str] = None, + vmm_server_id: Optional[str] = None, + cloud_id: Optional[str] = None, + template_id: Optional[str] = None, + checkpoint_type: Optional[str] = None, + checkpoints: Optional[List["Checkpoint"]] = None, + availability_sets: Optional[List["AvailabilitySetListItem"]] = None, + os_profile: Optional["OsProfile"] = None, + hardware_profile: Optional["HardwareProfile"] = None, + network_profile: Optional["NetworkProfile"] = None, + storage_profile: Optional["StorageProfile"] = None, + vm_name: Optional[str] = None, + uuid: Optional[str] = None, + generation: Optional[int] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword extended_location: Required. The extended location. + :paramtype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource. + :paramtype inventory_item_id: str + :keyword vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :paramtype vmm_server_id: str + :keyword cloud_id: ARM Id of the cloud resource to use for deploying the vm. + :paramtype cloud_id: str + :keyword template_id: ARM Id of the template resource to use for deploying the vm. + :paramtype template_id: str + :keyword checkpoint_type: Type of checkpoint supported for the vm. + :paramtype checkpoint_type: str + :keyword checkpoints: Checkpoints in the vm. + :paramtype checkpoints: list[~azure.mgmt.scvmm.models.Checkpoint] + :keyword availability_sets: Availability Sets in vm. + :paramtype availability_sets: list[~azure.mgmt.scvmm.models.AvailabilitySetListItem] + :keyword os_profile: OS properties. + :paramtype os_profile: ~azure.mgmt.scvmm.models.OsProfile + :keyword hardware_profile: Hardware properties. + :paramtype hardware_profile: ~azure.mgmt.scvmm.models.HardwareProfile + :keyword network_profile: Network properties. + :paramtype network_profile: ~azure.mgmt.scvmm.models.NetworkProfile + :keyword storage_profile: Storage properties. + :paramtype storage_profile: ~azure.mgmt.scvmm.models.StorageProfile + :keyword vm_name: VMName is the name of VM on the SCVMM server. + :paramtype vm_name: str + :keyword uuid: Unique ID of the virtual machine. + :paramtype uuid: str + :keyword generation: Gets or sets the generation for the vm. + :paramtype generation: int + """ + super(VirtualMachine, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + self.extended_location = extended_location + self.inventory_item_id = inventory_item_id + self.vmm_server_id = vmm_server_id + self.cloud_id = cloud_id + self.template_id = template_id + self.checkpoint_type = checkpoint_type + self.checkpoints = checkpoints + self.availability_sets = availability_sets + self.os_profile = os_profile + self.hardware_profile = hardware_profile + self.network_profile = network_profile + self.storage_profile = storage_profile + self.vm_name = vm_name + self.uuid = uuid + self.generation = generation + self.power_state = None + self.provisioning_state = None + + +class VirtualMachineCreateCheckpoint(msrest.serialization.Model): + """Defines the create checkpoint action properties. + + :ivar name: Name of the checkpoint. + :vartype name: str + :ivar description: Description of the checkpoint. + :vartype description: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the checkpoint. + :paramtype name: str + :keyword description: Description of the checkpoint. + :paramtype description: str + """ + super(VirtualMachineCreateCheckpoint, self).__init__(**kwargs) + self.name = name + self.description = description + + +class VirtualMachineDeleteCheckpoint(msrest.serialization.Model): + """Defines the delete checkpoint action properties. + + :ivar id: ID of the checkpoint to be deleted. + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: ID of the checkpoint to be deleted. + :paramtype id: str + """ + super(VirtualMachineDeleteCheckpoint, self).__init__(**kwargs) + self.id = id + + +class VirtualMachineInventoryItem(InventoryItemProperties): + """The Virtual machine inventory item. + + 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 inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "Cloud", "VirtualNetwork", "VirtualMachineTemplate", "VirtualMachine". + :vartype inventory_type: str or ~azure.mgmt.scvmm.models.InventoryType + :ivar managed_resource_id: Gets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar uuid: Gets the UUID (which is assigned by VMM) for the inventory item. + :vartype uuid: str + :ivar inventory_item_name: Gets the Managed Object name in VMM for the inventory item. + :vartype inventory_item_name: str + :ivar provisioning_state: Gets the provisioning state. + :vartype provisioning_state: str + :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + "Other". + :vartype os_type: str or ~azure.mgmt.scvmm.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar power_state: Gets the power state of the virtual machine. + :vartype power_state: str + :ivar ip_addresses: Gets or sets the nic ip addresses. + :vartype ip_addresses: list[str] + :ivar cloud: Cloud inventory resource details where the VM is present. + :vartype cloud: ~azure.mgmt.scvmm.models.InventoryItemDetails + """ + + _validation = { + 'inventory_type': {'required': True}, + 'managed_resource_id': {'readonly': True}, + 'uuid': {'readonly': True}, + 'inventory_item_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'os_type': {'readonly': True}, + 'os_name': {'readonly': True}, + 'power_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'uuid': {'key': 'uuid', 'type': 'str'}, + 'inventory_item_name': {'key': 'inventoryItemName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'os_name': {'key': 'osName', 'type': 'str'}, + 'power_state': {'key': 'powerState', 'type': 'str'}, + 'ip_addresses': {'key': 'ipAddresses', 'type': '[str]'}, + 'cloud': {'key': 'cloud', 'type': 'InventoryItemDetails'}, + } + + def __init__( + self, + *, + ip_addresses: Optional[List[str]] = None, + cloud: Optional["InventoryItemDetails"] = None, + **kwargs + ): + """ + :keyword ip_addresses: Gets or sets the nic ip addresses. + :paramtype ip_addresses: list[str] + :keyword cloud: Cloud inventory resource details where the VM is present. + :paramtype cloud: ~azure.mgmt.scvmm.models.InventoryItemDetails + """ + super(VirtualMachineInventoryItem, self).__init__(**kwargs) + self.inventory_type = 'VirtualMachine' # type: str + self.os_type = None + self.os_name = None + self.power_state = None + self.ip_addresses = ip_addresses + self.cloud = cloud + + +class VirtualMachineListResult(msrest.serialization.Model): + """List of VirtualMachines. + + :ivar value: List of VirtualMachines. + :vartype value: list[~azure.mgmt.scvmm.models.VirtualMachine] + :ivar next_link: Url to follow for getting next page of resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[VirtualMachine]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["VirtualMachine"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of VirtualMachines. + :paramtype value: list[~azure.mgmt.scvmm.models.VirtualMachine] + :keyword next_link: Url to follow for getting next page of resources. + :paramtype next_link: str + """ + super(VirtualMachineListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class VirtualMachineRestoreCheckpoint(msrest.serialization.Model): + """Defines the restore checkpoint action properties. + + :ivar id: ID of the checkpoint to be restored to. + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: ID of the checkpoint to be restored to. + :paramtype id: str + """ + super(VirtualMachineRestoreCheckpoint, self).__init__(**kwargs) + self.id = id + + +class VirtualMachineTemplate(msrest.serialization.Model): + """The VirtualMachineTemplates resource definition. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :ivar type: Resource Type. + :vartype type: str + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.scvmm.models.SystemData + :ivar extended_location: Required. The extended location. + :vartype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource. + :vartype inventory_item_id: str + :ivar uuid: Unique ID of the virtual machine template. + :vartype uuid: str + :ivar vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :vartype vmm_server_id: str + :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + "Other". + :vartype os_type: str or ~azure.mgmt.scvmm.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar computer_name: Gets or sets computer name. + :vartype computer_name: str + :ivar memory_mb: MemoryMB is the desired size of a virtual machine's memory, in MB. + :vartype memory_mb: int + :ivar cpu_count: Gets or sets the desired number of vCPUs for the vm. + :vartype cpu_count: int + :ivar limit_cpu_for_migration: Gets or sets a value indicating whether to enable processor + compatibility mode for live migration of VMs. Possible values include: "false", "true". + :vartype limit_cpu_for_migration: str or ~azure.mgmt.scvmm.models.LimitCpuForMigration + :ivar dynamic_memory_enabled: Gets or sets a value indicating whether to enable dynamic memory + or not. Possible values include: "false", "true". + :vartype dynamic_memory_enabled: str or ~azure.mgmt.scvmm.models.DynamicMemoryEnabled + :ivar is_customizable: Gets or sets a value indicating whether the vm template is customizable + or not. Possible values include: "false", "true". + :vartype is_customizable: str or ~azure.mgmt.scvmm.models.IsCustomizable + :ivar dynamic_memory_max_mb: Gets or sets the max dynamic memory for the vm. + :vartype dynamic_memory_max_mb: int + :ivar dynamic_memory_min_mb: Gets or sets the min dynamic memory for the vm. + :vartype dynamic_memory_min_mb: int + :ivar is_highly_available: Gets highly available property. + :vartype is_highly_available: str + :ivar generation: Gets or sets the generation for the vm. + :vartype generation: int + :ivar network_interfaces: Gets or sets the network interfaces of the template. + :vartype network_interfaces: list[~azure.mgmt.scvmm.models.NetworkInterfaces] + :ivar disks: Gets or sets the disks of the template. + :vartype disks: list[~azure.mgmt.scvmm.models.VirtualDisk] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'extended_location': {'required': True}, + 'uuid': {'min_length': 1}, + 'os_type': {'readonly': True}, + 'os_name': {'readonly': True}, + 'computer_name': {'readonly': True}, + 'memory_mb': {'readonly': True}, + 'cpu_count': {'readonly': True}, + 'limit_cpu_for_migration': {'readonly': True}, + 'dynamic_memory_enabled': {'readonly': True}, + 'is_customizable': {'readonly': True}, + 'dynamic_memory_max_mb': {'readonly': True}, + 'dynamic_memory_min_mb': {'readonly': True}, + 'is_highly_available': {'readonly': True}, + 'generation': {'readonly': True}, + 'network_interfaces': {'readonly': True}, + 'disks': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'vmm_server_id': {'key': 'properties.vmmServerId', 'type': 'str'}, + 'os_type': {'key': 'properties.osType', 'type': 'str'}, + 'os_name': {'key': 'properties.osName', 'type': 'str'}, + 'computer_name': {'key': 'properties.computerName', 'type': 'str'}, + 'memory_mb': {'key': 'properties.memoryMB', 'type': 'int'}, + 'cpu_count': {'key': 'properties.cpuCount', 'type': 'int'}, + 'limit_cpu_for_migration': {'key': 'properties.limitCpuForMigration', 'type': 'str'}, + 'dynamic_memory_enabled': {'key': 'properties.dynamicMemoryEnabled', 'type': 'str'}, + 'is_customizable': {'key': 'properties.isCustomizable', 'type': 'str'}, + 'dynamic_memory_max_mb': {'key': 'properties.dynamicMemoryMaxMB', 'type': 'int'}, + 'dynamic_memory_min_mb': {'key': 'properties.dynamicMemoryMinMB', 'type': 'int'}, + 'is_highly_available': {'key': 'properties.isHighlyAvailable', 'type': 'str'}, + 'generation': {'key': 'properties.generation', 'type': 'int'}, + 'network_interfaces': {'key': 'properties.networkInterfaces', 'type': '[NetworkInterfaces]'}, + 'disks': {'key': 'properties.disks', 'type': '[VirtualDisk]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: "ExtendedLocation", + tags: Optional[Dict[str, str]] = None, + inventory_item_id: Optional[str] = None, + uuid: Optional[str] = None, + vmm_server_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword extended_location: Required. The extended location. + :paramtype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource. + :paramtype inventory_item_id: str + :keyword uuid: Unique ID of the virtual machine template. + :paramtype uuid: str + :keyword vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :paramtype vmm_server_id: str + """ + super(VirtualMachineTemplate, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + self.extended_location = extended_location + self.inventory_item_id = inventory_item_id + self.uuid = uuid + self.vmm_server_id = vmm_server_id + self.os_type = None + self.os_name = None + self.computer_name = None + self.memory_mb = None + self.cpu_count = None + self.limit_cpu_for_migration = None + self.dynamic_memory_enabled = None + self.is_customizable = None + self.dynamic_memory_max_mb = None + self.dynamic_memory_min_mb = None + self.is_highly_available = None + self.generation = None + self.network_interfaces = None + self.disks = None + self.provisioning_state = None + + +class VirtualMachineTemplateInventoryItem(InventoryItemProperties): + """The Virtual machine template inventory item. + + 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 inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "Cloud", "VirtualNetwork", "VirtualMachineTemplate", "VirtualMachine". + :vartype inventory_type: str or ~azure.mgmt.scvmm.models.InventoryType + :ivar managed_resource_id: Gets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar uuid: Gets the UUID (which is assigned by VMM) for the inventory item. + :vartype uuid: str + :ivar inventory_item_name: Gets the Managed Object name in VMM for the inventory item. + :vartype inventory_item_name: str + :ivar provisioning_state: Gets the provisioning state. + :vartype provisioning_state: str + :ivar cpu_count: Gets or sets the desired number of vCPUs for the vm. + :vartype cpu_count: int + :ivar memory_mb: MemoryMB is the desired size of a virtual machine's memory, in MB. + :vartype memory_mb: int + :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + "Other". + :vartype os_type: str or ~azure.mgmt.scvmm.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'managed_resource_id': {'readonly': True}, + 'uuid': {'readonly': True}, + 'inventory_item_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'cpu_count': {'readonly': True}, + 'memory_mb': {'readonly': True}, + 'os_type': {'readonly': True}, + 'os_name': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'uuid': {'key': 'uuid', 'type': 'str'}, + 'inventory_item_name': {'key': 'inventoryItemName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'cpu_count': {'key': 'cpuCount', 'type': 'int'}, + 'memory_mb': {'key': 'memoryMB', 'type': 'int'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'os_name': {'key': 'osName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(VirtualMachineTemplateInventoryItem, self).__init__(**kwargs) + self.inventory_type = 'VirtualMachineTemplate' # type: str + self.cpu_count = None + self.memory_mb = None + self.os_type = None + self.os_name = None + + +class VirtualMachineTemplateListResult(msrest.serialization.Model): + """List of VirtualMachineTemplates. + + :ivar value: List of VirtualMachineTemplates. + :vartype value: list[~azure.mgmt.scvmm.models.VirtualMachineTemplate] + :ivar next_link: Url to follow for getting next page of resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[VirtualMachineTemplate]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["VirtualMachineTemplate"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of VirtualMachineTemplates. + :paramtype value: list[~azure.mgmt.scvmm.models.VirtualMachineTemplate] + :keyword next_link: Url to follow for getting next page of resources. + :paramtype next_link: str + """ + super(VirtualMachineTemplateListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class VirtualMachineUpdate(msrest.serialization.Model): + """Defines the virtualMachineUpdate. + + :ivar properties: Defines the resource properties. + :vartype properties: ~azure.mgmt.scvmm.models.VirtualMachineUpdateProperties + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'VirtualMachineUpdateProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + properties: Optional["VirtualMachineUpdateProperties"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword properties: Defines the resource properties. + :paramtype properties: ~azure.mgmt.scvmm.models.VirtualMachineUpdateProperties + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + """ + super(VirtualMachineUpdate, self).__init__(**kwargs) + self.properties = properties + self.tags = tags + + +class VirtualMachineUpdateProperties(msrest.serialization.Model): + """Defines the resource properties. + + :ivar hardware_profile: Defines the resource properties. + :vartype hardware_profile: ~azure.mgmt.scvmm.models.HardwareProfileUpdate + :ivar storage_profile: Defines the resource properties. + :vartype storage_profile: ~azure.mgmt.scvmm.models.StorageProfileUpdate + :ivar network_profile: Defines the resource properties. + :vartype network_profile: ~azure.mgmt.scvmm.models.NetworkProfileUpdate + :ivar availability_sets: Availability Sets in vm. + :vartype availability_sets: list[~azure.mgmt.scvmm.models.AvailabilitySetListItem] + """ + + _attribute_map = { + 'hardware_profile': {'key': 'hardwareProfile', 'type': 'HardwareProfileUpdate'}, + 'storage_profile': {'key': 'storageProfile', 'type': 'StorageProfileUpdate'}, + 'network_profile': {'key': 'networkProfile', 'type': 'NetworkProfileUpdate'}, + 'availability_sets': {'key': 'availabilitySets', 'type': '[AvailabilitySetListItem]'}, + } + + def __init__( + self, + *, + hardware_profile: Optional["HardwareProfileUpdate"] = None, + storage_profile: Optional["StorageProfileUpdate"] = None, + network_profile: Optional["NetworkProfileUpdate"] = None, + availability_sets: Optional[List["AvailabilitySetListItem"]] = None, + **kwargs + ): + """ + :keyword hardware_profile: Defines the resource properties. + :paramtype hardware_profile: ~azure.mgmt.scvmm.models.HardwareProfileUpdate + :keyword storage_profile: Defines the resource properties. + :paramtype storage_profile: ~azure.mgmt.scvmm.models.StorageProfileUpdate + :keyword network_profile: Defines the resource properties. + :paramtype network_profile: ~azure.mgmt.scvmm.models.NetworkProfileUpdate + :keyword availability_sets: Availability Sets in vm. + :paramtype availability_sets: list[~azure.mgmt.scvmm.models.AvailabilitySetListItem] + """ + super(VirtualMachineUpdateProperties, self).__init__(**kwargs) + self.hardware_profile = hardware_profile + self.storage_profile = storage_profile + self.network_profile = network_profile + self.availability_sets = availability_sets + + +class VirtualNetwork(msrest.serialization.Model): + """The VirtualNetworks resource definition. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :ivar type: Resource Type. + :vartype type: str + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.scvmm.models.SystemData + :ivar extended_location: Required. The extended location. + :vartype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource. + :vartype inventory_item_id: str + :ivar uuid: Unique ID of the virtual network. + :vartype uuid: str + :ivar vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :vartype vmm_server_id: str + :ivar network_name: Name of the virtual network in vmmServer. + :vartype network_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'extended_location': {'required': True}, + 'uuid': {'min_length': 1}, + 'network_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'vmm_server_id': {'key': 'properties.vmmServerId', 'type': 'str'}, + 'network_name': {'key': 'properties.networkName', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: "ExtendedLocation", + tags: Optional[Dict[str, str]] = None, + inventory_item_id: Optional[str] = None, + uuid: Optional[str] = None, + vmm_server_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword extended_location: Required. The extended location. + :paramtype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource. + :paramtype inventory_item_id: str + :keyword uuid: Unique ID of the virtual network. + :paramtype uuid: str + :keyword vmm_server_id: ARM Id of the vmmServer resource in which this resource resides. + :paramtype vmm_server_id: str + """ + super(VirtualNetwork, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + self.extended_location = extended_location + self.inventory_item_id = inventory_item_id + self.uuid = uuid + self.vmm_server_id = vmm_server_id + self.network_name = None + self.provisioning_state = None + + +class VirtualNetworkInventoryItem(InventoryItemProperties): + """The Virtual network inventory item. + + 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 inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "Cloud", "VirtualNetwork", "VirtualMachineTemplate", "VirtualMachine". + :vartype inventory_type: str or ~azure.mgmt.scvmm.models.InventoryType + :ivar managed_resource_id: Gets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar uuid: Gets the UUID (which is assigned by VMM) for the inventory item. + :vartype uuid: str + :ivar inventory_item_name: Gets the Managed Object name in VMM for the inventory item. + :vartype inventory_item_name: str + :ivar provisioning_state: Gets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'managed_resource_id': {'readonly': True}, + 'uuid': {'readonly': True}, + 'inventory_item_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'uuid': {'key': 'uuid', 'type': 'str'}, + 'inventory_item_name': {'key': 'inventoryItemName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(VirtualNetworkInventoryItem, self).__init__(**kwargs) + self.inventory_type = 'VirtualNetwork' # type: str + + +class VirtualNetworkListResult(msrest.serialization.Model): + """List of VirtualNetworks. + + :ivar value: List of VirtualNetworks. + :vartype value: list[~azure.mgmt.scvmm.models.VirtualNetwork] + :ivar next_link: Url to follow for getting next page of resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[VirtualNetwork]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["VirtualNetwork"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of VirtualNetworks. + :paramtype value: list[~azure.mgmt.scvmm.models.VirtualNetwork] + :keyword next_link: Url to follow for getting next page of resources. + :paramtype next_link: str + """ + super(VirtualNetworkListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class VMMServer(msrest.serialization.Model): + """The VmmServers resource definition. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :ivar type: Resource Type. + :vartype type: str + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.scvmm.models.SystemData + :ivar extended_location: Required. The extended location. + :vartype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :ivar credentials: Credentials to connect to VMMServer. + :vartype credentials: ~azure.mgmt.scvmm.models.VMMServerPropertiesCredentials + :ivar fqdn: Required. Fqdn is the hostname/ip of the vmmServer. + :vartype fqdn: str + :ivar port: Port is the port on which the vmmServer is listening. + :vartype port: int + :ivar connection_status: Gets or sets the connection status to the vmmServer. + :vartype connection_status: str + :ivar error_message: Gets or sets any error message if connection to vmmServer is having any + issue. + :vartype error_message: str + :ivar uuid: Unique ID of vmmServer. + :vartype uuid: str + :ivar version: Version is the version of the vmmSever. + :vartype version: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'extended_location': {'required': True}, + 'fqdn': {'required': True, 'min_length': 1}, + 'port': {'maximum': 65535, 'minimum': 1}, + 'connection_status': {'readonly': True}, + 'error_message': {'readonly': True}, + 'uuid': {'readonly': True}, + 'version': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'credentials': {'key': 'properties.credentials', 'type': 'VMMServerPropertiesCredentials'}, + 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, + 'port': {'key': 'properties.port', 'type': 'int'}, + 'connection_status': {'key': 'properties.connectionStatus', 'type': 'str'}, + 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: "ExtendedLocation", + fqdn: str, + tags: Optional[Dict[str, str]] = None, + credentials: Optional["VMMServerPropertiesCredentials"] = None, + port: Optional[int] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword extended_location: Required. The extended location. + :paramtype extended_location: ~azure.mgmt.scvmm.models.ExtendedLocation + :keyword credentials: Credentials to connect to VMMServer. + :paramtype credentials: ~azure.mgmt.scvmm.models.VMMServerPropertiesCredentials + :keyword fqdn: Required. Fqdn is the hostname/ip of the vmmServer. + :paramtype fqdn: str + :keyword port: Port is the port on which the vmmServer is listening. + :paramtype port: int + """ + super(VMMServer, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + self.extended_location = extended_location + self.credentials = credentials + self.fqdn = fqdn + self.port = port + self.connection_status = None + self.error_message = None + self.uuid = None + self.version = None + self.provisioning_state = None + + +class VMMServerListResult(msrest.serialization.Model): + """List of VmmServers. + + :ivar value: List of VmmServers. + :vartype value: list[~azure.mgmt.scvmm.models.VMMServer] + :ivar next_link: Url to follow for getting next page of resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[VMMServer]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["VMMServer"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of VmmServers. + :paramtype value: list[~azure.mgmt.scvmm.models.VMMServer] + :keyword next_link: Url to follow for getting next page of resources. + :paramtype next_link: str + """ + super(VMMServerListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class VMMServerPropertiesCredentials(msrest.serialization.Model): + """Credentials to connect to VMMServer. + + :ivar username: Username to use to connect to VMMServer. + :vartype username: str + :ivar password: Credentials to use to connect to VMMServer. + :vartype password: str + """ + + _attribute_map = { + 'username': {'key': 'username', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + } + + def __init__( + self, + *, + username: Optional[str] = None, + password: Optional[str] = None, + **kwargs + ): + """ + :keyword username: Username to use to connect to VMMServer. + :paramtype username: str + :keyword password: Credentials to use to connect to VMMServer. + :paramtype password: str + """ + super(VMMServerPropertiesCredentials, self).__init__(**kwargs) + self.username = username + self.password = password diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_scvmm_enums.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_scvmm_enums.py new file mode 100644 index 000000000000..530dc5bfda10 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/models/_scvmm_enums.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class AllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Allocation method. + """ + + DYNAMIC = "Dynamic" + STATIC = "Static" + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class CreateDiffDisk(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets a value indicating diff disk. + """ + + FALSE = "false" + TRUE = "true" + +class DynamicMemoryEnabled(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets a value indicating whether to enable dynamic memory or not. + """ + + FALSE = "false" + TRUE = "true" + +class InventoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The inventory type. + """ + + CLOUD = "Cloud" + VIRTUAL_NETWORK = "VirtualNetwork" + VIRTUAL_MACHINE_TEMPLATE = "VirtualMachineTemplate" + VIRTUAL_MACHINE = "VirtualMachine" + +class IsCustomizable(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets a value indicating whether the vm template is customizable or not. + """ + + FALSE = "false" + TRUE = "true" + +class LimitCpuForMigration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets a value indicating whether to enable processor compatibility mode for live + migration of VMs. + """ + + FALSE = "false" + TRUE = "true" + +class OsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Defines the different types of VM guest operating systems. + """ + + WINDOWS = "Windows" + LINUX = "Linux" + OTHER = "Other" diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/__init__.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/__init__.py new file mode 100644 index 000000000000..f3a65f5c15f0 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/__init__.py @@ -0,0 +1,27 @@ +# 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 ._vmm_servers_operations import VmmServersOperations +from ._operations import Operations +from ._clouds_operations import CloudsOperations +from ._virtual_networks_operations import VirtualNetworksOperations +from ._virtual_machines_operations import VirtualMachinesOperations +from ._virtual_machine_templates_operations import VirtualMachineTemplatesOperations +from ._availability_sets_operations import AvailabilitySetsOperations +from ._inventory_items_operations import InventoryItemsOperations + +__all__ = [ + 'VmmServersOperations', + 'Operations', + 'CloudsOperations', + 'VirtualNetworksOperations', + 'VirtualMachinesOperations', + 'VirtualMachineTemplatesOperations', + 'AvailabilitySetsOperations', + 'InventoryItemsOperations', +] diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_availability_sets_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_availability_sets_operations.py new file mode 100644 index 000000000000..24f8deadb519 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_availability_sets_operations.py @@ -0,0 +1,877 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + availability_set_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + availability_set_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + availability_set_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if force is not None: + _query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + subscription_id: str, + availability_set_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/availabilitySets") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AvailabilitySetsOperations(object): + """AvailabilitySetsOperations 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: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + availability_set_name: str, + **kwargs: Any + ) -> "_models.AvailabilitySet": + """Gets an AvailabilitySet. + + Implements AvailabilitySet GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilitySet, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.AvailabilitySet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('AvailabilitySet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.AvailabilitySet", + **kwargs: Any + ) -> "_models.AvailabilitySet": + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'AvailabilitySet') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if response.status_code == 201: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.AvailabilitySet", + **kwargs: Any + ) -> LROPoller["_models.AvailabilitySet"]: + """Implements AvailabilitySets PUT method. + + Onboards the ScVmm availability set as an Azure resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.AvailabilitySet + :keyword callable cls: A custom type 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 AvailabilitySet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.AvailabilitySet] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + availability_set_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + availability_set_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements AvailabilitySet DELETE method. + + Deregisters the ScVmm availability set from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.AvailabilitySet"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AvailabilitySet"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + availability_set_name=availability_set_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + availability_set_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> LROPoller["_models.AvailabilitySet"]: + """Implements the AvailabilitySets PATCH method. + + Updates the AvailabilitySets resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param availability_set_name: Name of the AvailabilitySet. + :type availability_set_name: str + :param body: AvailabilitySets patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 AvailabilitySet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.AvailabilitySet] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] + 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._update_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AvailabilitySet', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AvailabilitySetListResult"]: + """Implements GET AvailabilitySets in a resource group. + + List of AvailabilitySets in a resource group. + + :param resource_group_name: The name of the resource group. + :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 AvailabilitySetListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.AvailabilitySetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.AvailabilitySetListResult"]: + """Implements GET AvailabilitySets in a subscription. + + List of AvailabilitySets 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 AvailabilitySetListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.AvailabilitySetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/availabilitySets"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_clouds_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_clouds_operations.py new file mode 100644 index 000000000000..31aa93e2e94d --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_clouds_operations.py @@ -0,0 +1,865 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + cloud_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudName": _SERIALIZER.url("cloud_name", cloud_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + cloud_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudName": _SERIALIZER.url("cloud_name", cloud_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + cloud_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudName": _SERIALIZER.url("cloud_name", cloud_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if force is not None: + _query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + subscription_id: str, + cloud_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cloudName": _SERIALIZER.url("cloud_name", cloud_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/clouds") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class CloudsOperations(object): + """CloudsOperations 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: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + cloud_name: str, + **kwargs: Any + ) -> "_models.Cloud": + """Gets a Cloud. + + Implements Cloud GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cloud, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.Cloud + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cloud_name=cloud_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('Cloud', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.Cloud", + **kwargs: Any + ) -> "_models.Cloud": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'Cloud') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cloud_name=cloud_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Cloud', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Cloud', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.Cloud", + **kwargs: Any + ) -> LROPoller["_models.Cloud"]: + """Implements Clouds PUT method. + + Onboards the ScVmm fabric cloud as an Azure cloud resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.Cloud + :keyword callable cls: A custom type 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 Cloud or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.Cloud] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + cloud_name=cloud_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Cloud', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cloud_name=cloud_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements Cloud resource DELETE method. + + Deregisters the ScVmm fabric cloud from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cloud_name=cloud_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.Cloud"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Cloud"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cloud_name=cloud_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Cloud', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Cloud', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cloud_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> LROPoller["_models.Cloud"]: + """Implements the Clouds PATCH method. + + Updates the Clouds resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cloud_name: Name of the Cloud. + :type cloud_name: str + :param body: Clouds patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 Cloud or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.Cloud] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Cloud"] + 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._update_initial( + resource_group_name=resource_group_name, + cloud_name=cloud_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Cloud', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.CloudListResult"]: + """Implements GET Clouds in a resource group. + + List of Clouds in a resource group. + + :param resource_group_name: The name of the resource group. + :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 CloudListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.CloudListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CloudListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.CloudListResult"]: + """Implements GET Clouds in a subscription. + + List of Clouds 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 CloudListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.CloudListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CloudListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/clouds"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_inventory_items_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_inventory_items_operations.py new file mode 100644 index 000000000000..56c00217c5f3 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_inventory_items_operations.py @@ -0,0 +1,492 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + subscription_id: str, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + "inventoryItemName": _SERIALIZER.url("inventory_item_name", inventory_item_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + "inventoryItemName": _SERIALIZER.url("inventory_item_name", inventory_item_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + "inventoryItemName": _SERIALIZER.url("inventory_item_name", inventory_item_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_vmm_server_request( + subscription_id: str, + resource_group_name: str, + vmm_server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class InventoryItemsOperations(object): + """InventoryItemsOperations 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: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def create( + self, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + body: Optional["_models.InventoryItem"] = None, + **kwargs: Any + ) -> "_models.InventoryItem": + """Implements InventoryItem PUT method. + + Create Or Update InventoryItem. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.InventoryItem + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.InventoryItem + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'InventoryItem') + else: + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('InventoryItem', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> "_models.InventoryItem": + """Implements GET InventoryItem method. + + Shows an inventory item. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.InventoryItem + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('InventoryItem', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vmm_server_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> None: + """Implements inventoryItem DELETE method. + + Deletes an inventoryItem. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace + def list_by_vmm_server( + self, + resource_group_name: str, + vmm_server_name: str, + **kwargs: Any + ) -> Iterable["_models.InventoryItemsList"]: + """Implements GET for the list of Inventory Items in the VMMServer. + + Returns the list of inventoryItems in the given VMMServer. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InventoryItemsList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.InventoryItemsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItemsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_vmm_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + template_url=self.list_by_vmm_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_vmm_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("InventoryItemsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_vmm_server.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_operations.py new file mode 100644 index 000000000000..ba00a201bcca --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_operations.py @@ -0,0 +1,145 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +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: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ScVmm/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.ResourceProviderOperationList"]: + """Returns list of all operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ScVmm/operations"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machine_templates_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machine_templates_operations.py new file mode 100644 index 000000000000..867d9a1c1a91 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machine_templates_operations.py @@ -0,0 +1,869 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_template_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_template_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_template_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if force is not None: + _query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_template_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachineTemplates") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class VirtualMachineTemplatesOperations(object): + """VirtualMachineTemplatesOperations 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: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + virtual_machine_template_name: str, + **kwargs: Any + ) -> "_models.VirtualMachineTemplate": + """Gets a VirtualMachineTemplate. + + Implements VirtualMachineTemplate GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VirtualMachineTemplate + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.VirtualMachineTemplate", + **kwargs: Any + ) -> "_models.VirtualMachineTemplate": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualMachineTemplate') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.VirtualMachineTemplate", + **kwargs: Any + ) -> LROPoller["_models.VirtualMachineTemplate"]: + """Implements VirtualMachineTemplates PUT method. + + Onboards the ScVmm VM Template as an Azure VM Template resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineTemplate + :keyword callable cls: A custom type 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 VirtualMachineTemplate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VirtualMachineTemplate] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements VirtualMachineTemplate DELETE method. + + Deregisters the ScVmm VM Template from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.VirtualMachineTemplate"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineTemplate"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> LROPoller["_models.VirtualMachineTemplate"]: + """Implements the VirtualMachineTemplate PATCH method. + + Updates the VirtualMachineTemplate resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the VirtualMachineTemplate. + :type virtual_machine_template_name: str + :param body: VirtualMachineTemplates patch details. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 VirtualMachineTemplate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VirtualMachineTemplate] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] + 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._update_initial( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineTemplateListResult"]: + """Implements GET VirtualMachineTemplates in a resource group. + + List of VirtualMachineTemplates in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VirtualMachineTemplateListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VirtualMachineTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineTemplateListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineTemplateListResult"]: + """Implements GET VirtualMachineTemplates in a subscription. + + List of VirtualMachineTemplates 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 VirtualMachineTemplateListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VirtualMachineTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineTemplateListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachineTemplates"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machines_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machines_operations.py new file mode 100644 index 000000000000..86f26bc55bf0 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_machines_operations.py @@ -0,0 +1,1819 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + *, + retain: Optional[bool] = None, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if retain is not None: + _query_parameters['retain'] = _SERIALIZER.query("retain", retain, 'bool') + if force is not None: + _query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_start_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/start") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_restart_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restart") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_checkpoint_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/createCheckpoint") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_checkpoint_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/deleteCheckpoint") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_restore_checkpoint_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restoreCheckpoint") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachines") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods + """VirtualMachinesOperations 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: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> "_models.VirtualMachine": + """Gets a VirtualMachine. + + Implements VirtualMachine GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachine", + **kwargs: Any + ) -> "_models.VirtualMachine": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualMachine') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachine", + **kwargs: Any + ) -> LROPoller["_models.VirtualMachine"]: + """Implements VirtualMachines PUT method. + + Creates Or Updates virtual machines deployed on scvmm fabric. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VirtualMachine + :keyword callable cls: A custom type 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 VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VirtualMachine] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachine', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + retain: Optional[bool] = None, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + retain=retain, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + retain: Optional[bool] = None, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements VirtualMachine DELETE method. + + Deletes a VirtualMachine deployed on ScVmm fabric. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param retain: Whether to just disable the VM from azure and retain the VM in the VMM. Default + value is None. + :type retain: bool + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + retain=retain, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachineUpdate", + **kwargs: Any + ) -> Optional["_models.VirtualMachine"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachine"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualMachineUpdate') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: "_models.VirtualMachineUpdate", + **kwargs: Any + ) -> LROPoller["_models.VirtualMachine"]: + """Implements the VirtualMachines PATCH method. + + Updates the VirtualMachines resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: VirtualMachines patch payload. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineUpdate + :keyword callable cls: A custom type 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 VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VirtualMachine] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + 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._update_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualMachine', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}"} # type: ignore + + def _stop_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.StopVirtualMachineOptions"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'StopVirtualMachineOptions') + else: + _json = None + + request = build_stop_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/stop"} # type: ignore + + + @distributed_trace + def begin_stop( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.StopVirtualMachineOptions"] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to stop a virtual machine. + + Stop virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine stop action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.StopVirtualMachineOptions + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._stop_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/stop"} # type: ignore + + def _start_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_start_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/start"} # type: ignore + + + @distributed_trace + def begin_start( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to start a virtual machine. + + Start virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/start"} # type: ignore + + def _restart_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_restart_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + + @distributed_trace + def begin_restart( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to restart a virtual machine. + + Restart virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._restart_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + def _create_checkpoint_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineCreateCheckpoint"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineCreateCheckpoint') + else: + _json = None + + request = build_create_checkpoint_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_checkpoint_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _create_checkpoint_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/createCheckpoint"} # type: ignore + + + @distributed_trace + def begin_create_checkpoint( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineCreateCheckpoint"] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to creates a checkpoint in a virtual machine. + + Creates a checkpoint in virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine create checkpoint action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineCreateCheckpoint + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_checkpoint_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_checkpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/createCheckpoint"} # type: ignore + + def _delete_checkpoint_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineDeleteCheckpoint"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineDeleteCheckpoint') + else: + _json = None + + request = build_delete_checkpoint_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._delete_checkpoint_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _delete_checkpoint_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/deleteCheckpoint"} # type: ignore + + + @distributed_trace + def begin_delete_checkpoint( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineDeleteCheckpoint"] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to delete a checkpoint in a virtual machine. + + Deletes a checkpoint in virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine delete checkpoint action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineDeleteCheckpoint + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_checkpoint_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_checkpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/deleteCheckpoint"} # type: ignore + + def _restore_checkpoint_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineRestoreCheckpoint"] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineRestoreCheckpoint') + else: + _json = None + + request = build_restore_checkpoint_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._restore_checkpoint_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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, {}) + + _restore_checkpoint_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restoreCheckpoint"} # type: ignore + + + @distributed_trace + def begin_restore_checkpoint( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineRestoreCheckpoint"] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to restores to a checkpoint in a virtual machine. + + Restores to a checkpoint in virtual machine. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_machine_name: Name of the VirtualMachine. + :type virtual_machine_name: str + :param body: Virtualmachine restore checkpoint action payload. Default value is None. + :type body: ~azure.mgmt.scvmm.models.VirtualMachineRestoreCheckpoint + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._restore_checkpoint_initial( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restore_checkpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restoreCheckpoint"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineListResult"]: + """Implements GET VirtualMachines in a resource group. + + List of VirtualMachines in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VirtualMachineListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VirtualMachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineListResult"]: + """Implements GET VirtualMachines in a subscription. + + List of VirtualMachines 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 VirtualMachineListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VirtualMachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachines"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_networks_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_networks_operations.py new file mode 100644 index 000000000000..a22727b42000 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_virtual_networks_operations.py @@ -0,0 +1,869 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if force is not None: + _query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + subscription_id: str, + virtual_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualNetworks") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class VirtualNetworksOperations(object): + """VirtualNetworksOperations 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: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + virtual_network_name: str, + **kwargs: Any + ) -> "_models.VirtualNetwork": + """Gets a VirtualNetwork. + + Implements VirtualNetwork GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VirtualNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.VirtualNetwork", + **kwargs: Any + ) -> "_models.VirtualNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VirtualNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.VirtualNetwork", + **kwargs: Any + ) -> LROPoller["_models.VirtualNetwork"]: + """Implements VirtualNetworks PUT method. + + Onboards the ScVmm virtual network as an Azure virtual network resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VirtualNetwork + :keyword callable cls: A custom type 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 VirtualNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VirtualNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements VirtualNetwork DELETE method. + + Deregisters the ScVmm virtual network from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.VirtualNetwork"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetwork"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + virtual_network_name=virtual_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + virtual_network_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> LROPoller["_models.VirtualNetwork"]: + """Implements the VirtualNetworks PATCH method. + + Updates the VirtualNetworks resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param virtual_network_name: Name of the VirtualNetwork. + :type virtual_network_name: str + :param body: VirtualNetworks patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 VirtualNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VirtualNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] + 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._update_initial( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworkListResult"]: + """Implements GET VirtualNetworks in a resource group. + + List of VirtualNetworks in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VirtualNetworkListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VirtualNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworkListResult"]: + """Implements GET VirtualNetworks in a subscription. + + List of VirtualNetworks 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 VirtualNetworkListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VirtualNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualNetworks"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_vmm_servers_operations.py b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_vmm_servers_operations.py new file mode 100644 index 000000000000..48e2714c1c2e --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/operations/_vmm_servers_operations.py @@ -0,0 +1,865 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + vmm_server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + vmm_server_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + vmm_server_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if force is not None: + _query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + subscription_id: str, + vmm_server_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "vmmServerName": _SERIALIZER.url("vmm_server_name", vmm_server_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/vmmServers") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class VmmServersOperations(object): + """VmmServersOperations 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: ~azure.mgmt.scvmm.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + vmm_server_name: str, + **kwargs: Any + ) -> "_models.VMMServer": + """Gets a VMMServer. + + Implements VMMServer GET method. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VMMServer, or the result of cls(response) + :rtype: ~azure.mgmt.scvmm.models.VMMServer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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]: + 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('VMMServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.VMMServer", + **kwargs: Any + ) -> "_models.VMMServer": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'VMMServer') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.VMMServer", + **kwargs: Any + ) -> LROPoller["_models.VMMServer"]: + """Implements VmmServers PUT method. + + Onboards the SCVMM fabric as an Azure VmmServer resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param body: Request payload. + :type body: ~azure.mgmt.scvmm.models.VMMServer + :keyword callable cls: A custom type 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 VMMServer or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VMMServer] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VMMServer', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vmm_server_name: str, + force: Optional[bool] = None, + **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 = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vmm_server_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements VmmServers DELETE method. + + Deboards the SCVMM fabric from Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param force: Forces the resource to be deleted from azure. The corresponding CR would be + attempted to be deleted too. Default value is None. + :type force: bool + :keyword callable cls: A custom type 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 + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> Optional["_models.VMMServer"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VMMServer"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResourcePatch') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vmm_server_name=vmm_server_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VMMServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + vmm_server_name: str, + body: "_models.ResourcePatch", + **kwargs: Any + ) -> LROPoller["_models.VMMServer"]: + """Implements VmmServers PATCH method. + + Updates the VmmServers resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param vmm_server_name: Name of the VMMServer. + :type vmm_server_name: str + :param body: VmmServers patch payload. + :type body: ~azure.mgmt.scvmm.models.ResourcePatch + :keyword callable cls: A custom type 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 VMMServer or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.scvmm.models.VMMServer] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServer"] + 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._update_initial( + resource_group_name=resource_group_name, + vmm_server_name=vmm_server_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VMMServer', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VMMServerListResult"]: + """Implements GET VmmServers in a resource group. + + List of VmmServers in a resource group. + + :param resource_group_name: The name of the resource group. + :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 VMMServerListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VMMServerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VMMServerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.VMMServerListResult"]: + """Implements GET VmmServers in a subscription. + + List of VmmServers 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 VMMServerListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.scvmm.models.VMMServerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-06-05-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMMServerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VMMServerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/vmmServers"} # type: ignore diff --git a/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/py.typed b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/azure/mgmt/scvmm/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/scvmm/azure-mgmt-scvmm/sdk_packaging.toml b/sdk/scvmm/azure-mgmt-scvmm/sdk_packaging.toml new file mode 100644 index 000000000000..ac020aa1d5fe --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-scvmm" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/scvmm/azure-mgmt-scvmm/setup.py b/sdk/scvmm/azure-mgmt-scvmm/setup.py new file mode 100644 index 000000000000..4a68a236df4d --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/setup.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-scvmm" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/scvmm/ci.yml b/sdk/scvmm/ci.yml new file mode 100644 index 000000000000..864adefc34d4 --- /dev/null +++ b/sdk/scvmm/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/scvmm/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/scvmm/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: scvmm + Artifacts: + - name: azure-mgmt-scvmm + safeName: azuremgmtscvmm